diff --git a/gnoemoe/widgets/gm-app-view.c b/gnoemoe/widgets/gm-app-view.c index 687d143..7f5ddda 100644 --- a/gnoemoe/widgets/gm-app-view.c +++ b/gnoemoe/widgets/gm-app-view.c @@ -66,6 +66,8 @@ gboolean on_gm_app_view_notebook_button_release(GtkNotebook *notebook, GdkEventButton *event, GmAppView *view); void on_gm_app_view_check_button_search_direction_toggled( GtkToggleButton *button, GmAppView *view); +void on_gm_app_view_check_button_search_sensitive_toggled( + GtkToggleButton *button, GmAppView *view); gboolean on_gm_app_view_tray_button_press(GmTray *tray, GdkEventButton *event, GmAppView *view); @@ -140,6 +142,7 @@ struct _GmAppViewPrivate { GtkHBox *hbox_control_find; GtkHBox *hbox_replace; GtkCheckButton *check_button_search_direction; + GtkCheckButton *check_button_search_sensitive; gboolean ignore_toggling; gboolean drag_in_progress; @@ -331,8 +334,7 @@ gm_app_view_create_search_box(GmAppView *view) { GtkWidget *entry; GtkWidget *button; GtkWidget *align; - GtkWidget *check_button = - gtk_check_button_new_with_label(_("Search backwards")); + GtkWidget *check_button; GtkWidget *button_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE); GtkWidget *separator = gtk_hseparator_new(); GtkWidget *expander = gtk_expander_new(NULL); @@ -381,7 +383,22 @@ gm_app_view_create_search_box(GmAppView *view) { gtk_box_pack_start(GTK_BOX(hbox_control), entry, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_control), button, FALSE, FALSE, 0); + + check_button = gtk_check_button_new_with_label(_("Search backwards")); + g_signal_connect(check_button, "toggled", + G_CALLBACK(on_gm_app_view_check_button_search_direction_toggled), + view); + view->priv->check_button_search_direction = GTK_CHECK_BUTTON(check_button); gtk_box_pack_start(GTK_BOX(hbox_control), check_button, FALSE, FALSE, 0); + + check_button = gtk_check_button_new_with_label(_("Match case")); + g_signal_connect(check_button, "toggled", + G_CALLBACK(on_gm_app_view_check_button_search_sensitive_toggled), + view); + view->priv->check_button_search_sensitive = GTK_CHECK_BUTTON(check_button); + gtk_box_pack_start(GTK_BOX(hbox_control), check_button, FALSE, FALSE, 0); + + gtk_box_pack_start(GTK_BOX(hbox), hbox_control, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(hbox), button_close, FALSE, FALSE, 0); @@ -409,7 +426,6 @@ gm_app_view_create_search_box(GmAppView *view) { view->priv->hbox_replace = GTK_HBOX(hbox); view->priv->vbox_find = GTK_VBOX(vbox); view->priv->hbox_control_find = GTK_HBOX(hbox_control); - view->priv->check_button_search_direction = GTK_CHECK_BUTTON(check_button); view->priv->ignore_toggling = FALSE; gtk_widget_show_all(vbox); @@ -419,9 +435,6 @@ gm_app_view_create_search_box(GmAppView *view) { g_signal_connect(button_close, "clicked", G_CALLBACK(on_gm_app_view_button_find_close_clicked), view); - g_signal_connect(check_button, "toggled", - G_CALLBACK(on_gm_app_view_check_button_search_direction_toggled), - view); return vbox; } @@ -565,17 +578,19 @@ gm_app_view_init(GmAppView *view) { GmAppView * gm_app_view_new(GmApp *application) { GmAppView *view = GM_APP_VIEW(g_object_new(GM_TYPE_APP_VIEW, NULL)); - gboolean dir; view->priv->application = application; view->priv->active_world = NULL; // Toggle search direction - dir = gm_options_get_int(gm_app_options(application), "search_direction_world") - == 1; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( - view->priv->check_button_search_direction), dir); + view->priv->check_button_search_direction), + gm_options_get_int(gm_app_options(application), + "search_direction_world")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( + view->priv->check_button_search_sensitive), + gm_options_get_int(gm_app_options(application), + "search_sensitive")); g_signal_connect(application, "world_added", G_CALLBACK(on_gm_app_view_world_added), view); @@ -728,7 +743,7 @@ gm_app_view_update_tray(GmAppView *view) { } if (!active) { - for (worlds = gm_app_worlds(gm_app_instance()); worlds; + for (worlds = gm_app_worlds(view->priv->application); worlds; worlds = worlds->next) { world = GM_WORLD(worlds->data); activity = gm_world_activity(world); @@ -895,7 +910,7 @@ on_gm_app_view_world_state_changing(GmWorld *world, GmNetState state, GmAppView *view) { if (world == gm_app_view_active_world(view)) { switch (state) { - case GM_NET_STATE_CONNECTED: + case GM_NET_STATE_CONNECTING: gm_app_view_update_connect_button(view, TRUE); break; case GM_NET_STATE_DISCONNECTED: @@ -1019,14 +1034,23 @@ on_gm_app_view_world_activate(GtkAction * action, GmWorld *world) { GmSearchableSearchFlags gm_app_view_search_flags(GmAppView *view) { + GmSearchableSearchFlags flags = 0; gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( view->priv->check_button_search_direction)); - + gboolean sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( + view->priv->check_button_search_sensitive)); + if (active) { - return GM_SEARCHABLE_SEARCH_BACKWARDS; + flags = GM_SEARCHABLE_SEARCH_BACKWARDS; } else { - return GM_SEARCHABLE_SEARCH_FORWARDS; + flags = GM_SEARCHABLE_SEARCH_FORWARDS; } + + if (!sensitive) { + flags |= GM_SEARCHABLE_SEARCH_CASE_INSENSITIVE; + } + + return flags; } gboolean @@ -1203,6 +1227,15 @@ on_gm_app_view_button_find_close_clicked(GtkButton *button, } } +void +on_gm_app_view_check_button_search_sensitive_toggled(GtkToggleButton *button, + GmAppView *view) { + gboolean active = gtk_toggle_button_get_active(button); + + gm_options_set_int(gm_app_options(view->priv->application), + "search_sensitive", active ? 1 : 0); +} + void on_gm_app_view_check_button_search_direction_toggled(GtkToggleButton *button, GmAppView *view) { @@ -1452,10 +1485,10 @@ on_gm_app_view_world_view_notebook_switch_page(GtkNotebook *notebook, } if (page_num == 0) { - direction = gm_options_get_int(gm_app_options(gm_app_instance()), + direction = gm_options_get_int(gm_app_options(view->priv->application), "search_direction_world"); } else { - direction = gm_options_get_int(gm_app_options(gm_app_instance()), + direction = gm_options_get_int(gm_app_options(view->priv->application), "search_direction"); } @@ -1577,10 +1610,10 @@ on_gm_app_view_world_connect(GtkMenuItem * menuitem, GmAppView *view) { GmWorld *world = gm_app_view_active_world(view); if (world != NULL) { - if (gm_world_connected(world)) { - gm_world_disconnect(world); - } else if (gm_world_disconnected(world)) { + if (gm_world_disconnected(world)) { gm_world_connect(world); + } else { + gm_world_disconnect(world); } } }