Initial commit

This commit is contained in:
Markus Koch 2015-09-07 18:37:29 +02:00
commit 8b20ac0461
8 changed files with 601 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.user
*~

19
CMakeLists.txt Normal file
View File

@ -0,0 +1,19 @@
project(konaclient-gtk)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
# Use the package PkgConfig to detect GTK+ headers/library files
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
# Setup CMake to use GTK+, tell the compiler where to look for headers
# and to the linker where to look for libraries
include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
# Add other flags to the compiler
add_definitions(${GTK3_CFLAGS_OTHER})
add_executable(${PROJECT_NAME} ${SRC_LIST})
# Link the target to the GTK+ libraries
target_link_libraries(${PROJECT_NAME} ${GTK3_LIBRARIES})

325
glade/mainWindow.glade Normal file
View File

@ -0,0 +1,325 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkEntryCompletion" id="searchCompletion"/>
<object class="GtkWindow" id="mainWindow">
<property name="width_request">640</property>
<property name="height_request">360</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">KonaClient</property>
<property name="icon_name">konaclient</property>
<signal name="destroy" handler="gtk_main_quit" swapped="no"/>
<child>
<object class="GtkBox" id="boxHsplit">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkPaned" id="mainPane">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">2</property>
<property name="margin_right">2</property>
<property name="wide_handle">True</property>
<child>
<object class="GtkBox" id="leftPaneBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkExpander" id="expanderSearch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expanded">True</property>
<child>
<object class="GtkBox" id="boxSearch">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkSearchEntry" id="entrySearch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<property name="completion">searchCompletion</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="boxSearchButtons">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">8</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="buttonSearchPosts">
<property name="label" translatable="yes">Posts</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="kona_search_posts" object="entrySearch" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonSearchPools">
<property name="label" translatable="yes">Pools</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="kona_search_pools" object="boxSearch" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="expanderSearchLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Search</property>
<property name="angle">0.01</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="expanderNavigation">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expanded">True</property>
<child>
<object class="GtkBox" id="boxNavigation">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkBox" id="boxJumpToPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">8</property>
<child>
<object class="GtkLabel" id="labelJumpToPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Jump to page:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinJumpToPage">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonJumpToPage">
<property name="label" translatable="yes">Go!</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="kona_jump_page" object="spinJumpToPage" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="expanderNavigationLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Navigation</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="expanderTags">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expanded">True</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindowTags">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="min_content_height">100</property>
<child>
<object class="GtkViewport" id="viewportTags">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkBox" id="boxTags">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="expanderTagsLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Tags</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="rightPaneScrolledWindow">
<property name="name">0</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkViewport" id="viewportPreview">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLevelBar" id="progressBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="value">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

52
glade/previewWidget.glade Normal file
View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkBox" id="previewWidget">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="image">
<property name="width_request">200</property>
<property name="height_request">150</property>
<property name="can_focus">False</property>
<property name="icon_name">applications-graphics</property>
<property name="use_fallback">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinner" id="spinner">
<property name="width_request">200</property>
<property name="height_request">150</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button">
<property name="label" translatable="yes">Download @ 0000 x 0000</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="kona_download_image" object="previewWidget" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkViewport" id="viewportTagItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="labelAdd">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;a href=""&gt;+&lt;/a&gt;</property>
<property name="use_markup">True</property>
<property name="mnemonic_widget">box1</property>
<signal name="activate-link" handler="gtk_main_quit" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="labelSet">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">&lt;a href=""&gt;tag_name&lt;/a&gt;</property>
<property name="use_markup">True</property>
<property name="mnemonic_widget">box1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="labelCount">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="margin_left">4</property>
<property name="label" translatable="yes">(#####)</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

56
main.c Normal file
View File

@ -0,0 +1,56 @@
#include <gtk/gtk.h>
#include "previewwidget.h"
int buildWindow();
int buildWindow() {
GtkWindow *mainWindow;
GtkBuilder *builder;
GtkWidget *previewLayout;
GtkWidget *previewContainer;
GtkWidget *temp;
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, "glade/mainWindow.glade", NULL);
mainWindow = GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(builder), "mainWindow"));
gtk_builder_connect_signals(builder, NULL);
previewContainer = gtk_builder_get_object(GTK_BUILDER(builder), "viewportPreview");
previewLayout = gtk_flow_box_new();
gtk_flow_box_set_max_children_per_line(GTK_FLOW_BOX(previewLayout), 200);
for (int i = 0; i < 100; ++i) {
// CUSTOM!!!!!
temp = PreviewWidget_new();
gtk_flow_box_insert(GTK_FLOW_BOX(previewLayout),temp,0);
gtk_widget_show(temp);
// -------------------
}
gtk_widget_show(previewLayout);
gtk_container_add(GTK_CONTAINER(previewContainer), previewLayout);
g_object_unref(G_OBJECT(builder));
gtk_widget_show(GTK_WIDGET(mainWindow));
}
int main(int argc, char **argv)
{
gtk_init(&argc, &argv);
buildWindow();
gtk_main();
return 0;
}
// REMEBER THIS FUNCTION: g_clear_object ()

56
previewwidget.c Normal file
View File

@ -0,0 +1,56 @@
#include "previewwidget.h"
G_DEFINE_TYPE(PreviewWidget, PreviewWidget, GTK_TYPE_BIN)
void kona_download_image( GtkWidget *widget, gpointer data )
{
PreviewWidget_set_image(data, ""); // DEBUG ONLY!
}
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
GtkWidget *spinner;
GList *widgets;
widgets = gtk_container_get_children(GTK_CONTAINER(widget));
spinner = widgets->data;
gtk_widget_set_visible(spinner, TRUE);
spinner = g_list_next(widgets)->data;
gtk_widget_set_visible(spinner, FALSE);
}
void PreviewWidget_class_init(PreviewWidgetClass *klass)
{
}
void PreviewWidget_init(PreviewWidget *klass)
{
GtkWidget *widget;
GtkBuilder *builder;
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, "glade/previewWidget.glade", NULL);
widget = GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(builder), "previewWidget"));
gtk_builder_connect_signals(builder, NULL);
gtk_container_add(GTK_CONTAINER(klass), widget);
GTK_WIDGET(gtk_builder_get_object(builder, "image"));
/*klass->image= GTK_WIDGET(gtk_builder_get_object(builder, "image"));
klass->button = GTK_WIDGET(gtk_builder_get_object(builder, "button"));
klass->spinner = GTK_WIDGET(gtk_builder_get_object(builder, "spinner"));*/
g_object_unref(G_OBJECT(builder));
}
GtkWidget *PreviewWidget_new()
{
return g_object_new (TYPE_PREVIEWWIDGET, NULL);
}
// TODO: DESTROY etc.

32
previewwidget.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef PREVIEWWIDGET_H
#define PREVIEWWIDGET_H
#include <gtk/gtk.h>
#include <glib.h>
G_BEGIN_DECLS
#define TYPE_PREVIEWWIDGET (PreviewWidget_get_type ())
#define PREVIEWWIDGET(obj) GTK_CHECK_CAST (obj, PreviewWidget_get_type (), PreviewWidget)
#define PREVIEWWIDGET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, previewwidget_get_type (), PreviewWidgetClass)
#define IS_PREVIEWWIDGET(obj) GTK_CHECK_TYPE (obj, previewwidget_get_type ())
typedef struct _PreviewWidget PreviewWidget;
typedef struct _PreviewWidgetClass PreviewWidgetClass;
struct _PreviewWidget {
GtkBin bin;
};
struct _PreviewWidgetClass {
GtkBinClass parent_class;
void (* PreviewWidget) (PreviewWidget *pvWidget);
};
GType PreviewWidget_get_type (void) G_GNUC_CONST;
GtkWidget* PreviewWidget_new (void);
G_END_DECLS
#endif // PREVIEWWIDGET_H