/gpump/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/gpump/trunk

« back to all changes in this revision

Viewing changes to src/GPumpApp.c

  • Committer: Gustav Hartvigsson
  • Date: 2015-06-05 19:06:14 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150605190614-s410mh65n2jdxtcv
* Cleaded up a lille code
* Fixed a nasty segfault that could occur if the conig folder did not exist.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil
2
 
 * vi: set shiftwidth=2 tabstop=2 expandtab:
3
 
 * :indentSize=2:tabSize=2:noTabs=true:
4
 
 */
5
 
 
6
 
#include "GPumpApp.h"
7
 
 
8
 
#define GPUMP_APP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
9
 
  GPUMP_TYPE_APP, GPumpAppPrivate))
10
 
 
11
 
G_DEFINE_TYPE (GPumpApp, gpump_app, GTK_TYPE_APPLICATION)
12
 
 
13
 
struct GPumpAppPrivate {
14
 
  
15
 
  GSettings * ui_settings;
16
 
  GSettings * login_settings;
17
 
  
18
 
  /* Widgets */
19
 
  GtkWidget * window;
20
 
  GtkWidget * header_bar;
21
 
  GtkWidget * layout; /* GtkBox */
22
 
  GtkWidget * post_list_view; /* GtkTreeView */
23
 
  
24
 
  /* List store */
25
 
  GtkListStore * post_list_store;
26
 
};
27
 
 
28
 
/* * Callback and private function declarations *******************************/
29
 
void gpump_app_class_init (GPumpAppClass * klass);
30
 
void gpump_app_activate (GApplication * application);
31
 
void gpump_app_init (GPumpApp * self);
32
 
 
33
 
typedef enum {
34
 
  GPUPM_APP_MAIN_LIST_COL = 0,
35
 
  GPUMP_APP_MAIN_LIST_NUM_COL
36
 
} GPumpAppCols;
37
 
 
38
 
/* * Class functions **********************************************************/
39
 
GPumpApp * gpump_app_new (void) {
40
 
  GPumpApp * self = g_object_new (GPUMP_TYPE_APP,
41
 
                       "application-id", "org.gego.gpump",
42
 
                       "flags",G_APPLICATION_FLAGS_NONE,
43
 
                       NULL);
44
 
  return self;
45
 
}
46
 
 
47
 
void gpump_app_init (GPumpApp * self) {
48
 
  // GPumpAppPrivate * priv = GPUMP_APP_GET_PRIVATE (self);
49
 
  /* Nothing to be done here? */
50
 
}
51
 
 
52
 
void gpump_app_class_init (GPumpAppClass * klass) {
53
 
  g_print("GPumpApp class init.\n");
54
 
  
55
 
  // GObject * object_class = G_OBJECT_CLASS (klass);
56
 
  GApplicationClass * application_class = G_APPLICATION_CLASS (klass);
57
 
  
58
 
  application_class->activate = gpump_app_activate;
59
 
  
60
 
  g_type_class_add_private (klass, sizeof(GPumpApp));
61
 
  
62
 
  g_print ("GPumpApp class init done.\n");
63
 
}
64
 
 
65
 
 
66
 
void gpump_app_activate (GApplication * application) {
67
 
  g_print ("GPumpApp activate.\n");
68
 
  
69
 
  /* Creating widgets */
70
 
  GPumpAppPrivate * priv = GPUMP_APP_GET_PRIVATE (application);
71
 
  GtkWidget * window = priv->window =
72
 
    gtk_application_window_new (GTK_APPLICATION (application));
73
 
  GtkWidget * header_bar = priv->header_bar = gtk_header_bar_new ();
74
 
  GtkWidget * layout = priv->layout = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
75
 
  
76
 
  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header_bar), TRUE);
77
 
  
78
 
  GtkListStore * post_list_store = priv->post_list_store =
79
 
    gtk_list_store_new ( GPUMP_APP_MAIN_LIST_NUM_COL, GTK_TYPE_WIDGET);
80
 
  
81
 
  GtkWidget * post_list_view = priv->post_list_view =
82
 
    gtk_tree_view_new ();
83
 
  
84
 
  
85
 
  gtk_tree_view_set_model (GTK_TREE_VIEW (post_list_view), GTK_TREE_MODEL(post_list_store));
86
 
  
87
 
  /* adding widgets */
88
 
  gtk_window_set_titlebar (GTK_WINDOW (window), header_bar);
89
 
  
90
 
  gtk_box_pack_start (GTK_BOX (layout), post_list_view, TRUE, TRUE, 1);
91
 
  
92
 
  gtk_container_add (GTK_CONTAINER (window), layout);
93
 
  
94
 
  /* Show it! */
95
 
  gtk_widget_show_all (GTK_WIDGET(window));
96
 
  
97
 
  g_print ("done GPumpApp activate.\n");
98
 
}
99
 
 
100
 
 
101
 
 
102
 
/* * Callback implemenations **************************************************/
103