static void bjb_window_base_finalize (GObject *object) { BjbWindowBase *self = BJB_WINDOW_BASE (object); BjbWindowBasePriv *priv = self->priv; g_clear_object (&priv->controller); G_OBJECT_CLASS (bjb_window_base_parent_class)->finalize (object); }
void bjb_window_base_set_tags(GtkWidget * win, GList * tags) { BjbWindowBase *b = BJB_WINDOW_BASE(win); if ( b->priv->tags != NULL ) g_list_free_full (b->priv->tags,(GDestroyNotify) g_free); b->priv->tags = tags ; }
void bjb_window_base_set_entry(GtkWidget *win, gchar *search_entry) { BjbWindowBase *bmw; g_return_if_fail (BJB_IS_WINDOW_BASE (win)); bmw = BJB_WINDOW_BASE (win); bmw->priv->entry = search_entry; }
GList * bjb_window_base_get_tags(GtkWidget * win) { BjbWindowBase *b = BJB_WINDOW_BASE(win); if ( b->priv ) return b->priv->tags ; else return NULL ; }
static gboolean on_key_pressed_cb (GtkWidget *w, GdkEvent *event, gpointer user_data) { BjbWindowBase *self = BJB_WINDOW_BASE (user_data); BjbWindowBasePriv *priv = self->priv; GdkModifierType modifiers; modifiers = gtk_accelerator_get_default_mod_mask (); /* First check for Alt <- to go back */ if ((event->key.state & modifiers) == GDK_MOD1_MASK && event->key.keyval == GDK_KEY_Left && priv->current_view == BJB_WINDOW_BASE_NOTE_VIEW) { BijiItemsGroup items; items = bjb_controller_get_group (priv->controller); if (items == BIJI_LIVING_ITEMS) bjb_window_base_switch_to (self, BJB_WINDOW_BASE_MAIN_VIEW); else if (items == BIJI_ARCHIVED_ITEMS) bjb_window_base_switch_to (self, BJB_WINDOW_BASE_ARCHIVE_VIEW); return TRUE; } switch (event->key.keyval) { /* Help on F1 */ case GDK_KEY_F1: help_activated (NULL, NULL, NULL); return TRUE; /* Reserve other func keys for window */ case GDK_KEY_F2: case GDK_KEY_F3: case GDK_KEY_F4: case GDK_KEY_F5: case GDK_KEY_F6: case GDK_KEY_F7: case GDK_KEY_F8: case GDK_KEY_F9: case GDK_KEY_F10: case GDK_KEY_F11: return TRUE; default: return FALSE; } return FALSE; }
BijiNoteBook * bjb_window_base_get_book(GtkWidget * win) { BjbWindowBase *b = BJB_WINDOW_BASE(win); if ( b->priv ) { return bijiben_get_book(BIJIBEN_APPLICATION(g_application_get_default())); } else { g_message("Can't get notes"); return NULL ; } }
static void bjb_window_base_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { BjbWindowBase *self = BJB_WINDOW_BASE (object); switch (property_id) { case PROP_NOTE: g_value_set_object (value, self->priv->note); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static gboolean bjb_application_window_configured (GtkWidget *widget, GdkEvent *event, gpointer user_data) { BjbWindowBase *win; GSettings *settings; GVariant *variant; GdkWindowState state; gint32 size[2]; gint32 position[2]; win = BJB_WINDOW_BASE (user_data); settings = G_SETTINGS (win->priv->settings); state = gdk_window_get_state (gtk_widget_get_window (widget)); if (state & GDK_WINDOW_STATE_MAXIMIZED) return FALSE; gtk_window_get_size (GTK_WINDOW (win), (gint *) &size[0], (gint *) &size[1]); variant = g_variant_new_fixed_array (G_VARIANT_TYPE_INT32, size, 2, sizeof (size[0])); g_settings_set_value (settings, "window-size", variant); gtk_window_get_position (GTK_WINDOW (win), (gint *) &position[0], (gint *) &position[1]); variant = g_variant_new_fixed_array (G_VARIANT_TYPE_INT32, position, 2, sizeof (position[0])); g_settings_set_value (settings, "window-position", variant); return FALSE; }
gchar * bjb_window_base_get_entry(GtkWidget *win) { BjbWindowBase *bmw = BJB_WINDOW_BASE(win); return bmw->priv->entry ; }
void bjb_window_base_delete_entry(GtkWidget *win) { BJB_WINDOW_BASE(win)->priv->entry = NULL ; }
PangoFontDescription * window_base_get_font(GtkWidget *window) { BjbWindowBase *b = BJB_WINDOW_BASE(window); return b->priv->font ; }
/* Gobj */ static void bjb_window_base_constructed (GObject *obj) { BjbWindowBase *self = BJB_WINDOW_BASE (obj); BjbWindowBasePriv *priv; gboolean maximized; const gint32 *position; const gint32 *size; gsize n_elements; GVariant *variant; G_OBJECT_CLASS (bjb_window_base_parent_class)->constructed (obj); priv = self->priv; priv->settings = bjb_app_get_settings ((gpointer) g_application_get_default ()); gtk_window_set_position (GTK_WINDOW (self),GTK_WIN_POS_CENTER); gtk_window_set_title (GTK_WINDOW (self), _(BIJIBEN_MAIN_WIN_TITLE)); variant = g_settings_get_value (G_SETTINGS (priv->settings), "window-size"); size = g_variant_get_fixed_array (variant, &n_elements, sizeof (gint32)); if (n_elements == 2) gtk_window_set_default_size (GTK_WINDOW (self), size[0], size[1]); g_variant_unref (variant); variant = g_settings_get_value (G_SETTINGS (priv->settings), "window-position"); position = g_variant_get_fixed_array (variant, &n_elements, sizeof (gint32)); if (n_elements == 2) gtk_window_move (GTK_WINDOW (self), position[0], position[1]); g_variant_unref (variant); maximized = g_settings_get_boolean (G_SETTINGS (priv->settings), "window-maximized"); if (maximized) gtk_window_maximize (GTK_WINDOW (self)); /* We probably want to offer a no entry window at first (startup) */ priv->entry = NULL ; priv->controller = bjb_controller_new (bijiben_get_manager (BIJIBEN_APPLICATION(g_application_get_default())), GTK_WINDOW (obj), priv->entry ); /* Shared toolbar */ priv->view = bjb_main_view_new (GTK_WIDGET (obj), priv->controller); priv->main_toolbar = bjb_main_toolbar_new (priv->view, priv->controller); gtk_window_set_titlebar (GTK_WINDOW (self), GTK_WIDGET (priv->main_toolbar)); /* Search entry toolbar */ priv->search_bar = bjb_search_toolbar_new (GTK_WIDGET (obj), priv->controller); gtk_box_pack_start (GTK_BOX (priv->vbox), GTK_WIDGET (priv->search_bar), FALSE, FALSE, 0); /* UI : stack for different views */ priv->stack = GTK_STACK (gtk_stack_new ()); gtk_box_pack_start (GTK_BOX (priv->vbox), GTK_WIDGET (priv->stack), TRUE, TRUE, 0); priv->spinner = gtk_spinner_new (); gtk_stack_add_named (priv->stack, priv->spinner, "spinner"); gtk_stack_set_visible_child_name (priv->stack, "spinner"); gtk_widget_show (priv->spinner); gtk_spinner_start (GTK_SPINNER (priv->spinner)); priv->no_note = bjb_empty_results_box_new (); gtk_stack_add_named (priv->stack, priv->no_note, "empty"); gtk_stack_add_named (priv->stack, GTK_WIDGET (priv->view), "main-view"); gtk_widget_show (GTK_WIDGET (priv->stack)); /* Connection to window signals */ g_signal_connect (GTK_WIDGET (self), "destroy", G_CALLBACK (bjb_window_base_destroy), self); g_signal_connect (self, "window-state-event", G_CALLBACK (bjb_application_window_state_changed), priv->settings); g_signal_connect (self, "configure-event", G_CALLBACK (bjb_application_window_configured), self); /* Keys */ g_signal_connect (GTK_WIDGET (self), "key-press-event", G_CALLBACK(on_key_pressed_cb), self); /* If a note is requested at creation, show it * This is a specific type of window not associated with any view */ if (priv->note == NULL) { bjb_window_base_switch_to (self, BJB_WINDOW_BASE_MAIN_VIEW); } else { priv->detached = TRUE; bjb_window_base_switch_to_item (self, BIJI_ITEM (priv->note)); } /* For some reason, do not gtk_widget_show _self_ * or gtk_application_get_menu_bar will run, * fire a warning, while app menu will not show up * you have been warned! * * This is probably due to the fact that, * at startup, we still are * inside... drums... gapplication startup () */ gtk_widget_show (priv->vbox); }
void switch_to_note_view (BjbMainView *self, BijiNoteObj *note) { bjb_main_view_disconnect_handlers (self); bjb_window_base_switch_to_item (BJB_WINDOW_BASE (self->priv->window), BIJI_ITEM (note)); }