/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
 
  GtkWidget * btn_gear;
24
 
  GtkWidget * btn_new_post;
25
 
  
26
 
  /* List store */
27
 
  GtkListStore * post_list_store;
28
 
};
29
 
 
30
 
/* * Callback and private function declarations *******************************/
31
 
void gpump_app_class_init (GPumpAppClass * klass);
32
 
void gpump_app_activate (GApplication * application);
33
 
void gpump_app_init (GPumpApp * self);
34
 
 
35
 
typedef enum {
36
 
  GPUPM_APP_MAIN_LIST_COL = 0,
37
 
  GPUMP_APP_MAIN_LIST_NUM_COL
38
 
} GPumpAppCols;
39
 
 
40
 
/* * Class functions **********************************************************/
41
 
GPumpApp * gpump_app_new (void) {
42
 
  GPumpApp * self = g_object_new (GPUMP_TYPE_APP,
43
 
                       "application-id", "org.gego.gpump",
44
 
                       "flags",G_APPLICATION_FLAGS_NONE,
45
 
                       NULL);
46
 
  return self;
47
 
}
48
 
 
49
 
void gpump_app_init (GPumpApp * self) {
50
 
  self->priv = GPUMP_APP_GET_PRIVATE (self);
51
 
}
52
 
 
53
 
void gpump_app_class_init (GPumpAppClass * klass) {
54
 
  g_print("GPumpApp class init.\n");
55
 
  
56
 
  // GObject * object_class = G_OBJECT_CLASS (klass);
57
 
  GApplicationClass * application_class = G_APPLICATION_CLASS (klass);
58
 
  
59
 
  application_class->activate = gpump_app_activate;
60
 
  
61
 
  g_type_class_add_private (klass, sizeof(GPumpApp));
62
 
  
63
 
  g_print ("GPumpApp class init done.\n");
64
 
}
65
 
 
66
 
 
67
 
void gpump_app_activate (GApplication * application) {
68
 
  g_print ("GPumpApp activate.\n");
69
 
  
70
 
  /* Creating widgets */
71
 
  GPumpAppPrivate * priv = GPUMP_APP_GET_PRIVATE (application);
72
 
  GtkWidget * window = priv->window =
73
 
    gtk_application_window_new (GTK_APPLICATION (application));
74
 
  GtkWidget * header_bar = priv->header_bar = gtk_header_bar_new ();
75
 
  GtkWidget * layout = priv->layout = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
76
 
  
77
 
  gtk_header_bar_set_title (GTK_HEADER_BAR (header_bar), "GPump");
78
 
  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header_bar), TRUE);
79
 
  
80
 
  /*
81
 
  GtkListStore * post_list_store = priv->post_list_store =
82
 
    gtk_list_store_new ( GPUMP_APP_MAIN_LIST_NUM_COL, GTK_TYPE_WIDGET);
83
 
  */
84
 
  GtkWidget * post_list_view = priv->post_list_view =
85
 
    gtk_tree_view_new ();
86
 
  
87
 
  /*
88
 
  gtk_tree_view_set_model (GTK_TREE_VIEW (post_list_view), GTK_TREE_MODEL(post_list_store));
89
 
  */
90
 
  /* adding widgets */
91
 
  gtk_window_set_titlebar (GTK_WINDOW (window), header_bar);
92
 
  
93
 
  gtk_box_pack_start (GTK_BOX (layout), post_list_view, TRUE, TRUE, 1);
94
 
  
95
 
  gtk_container_add (GTK_CONTAINER (window), layout);
96
 
  
97
 
  /* Show it! */
98
 
  gtk_widget_show_all (GTK_WIDGET(window));
99
 
  
100
 
  g_print ("done GPumpApp activate.\n");
101
 
}
102
 
 
103
 
 
104
 
 
105
 
/* * Callback implemenations **************************************************/
106