static void clock_settings_changed_cb (GSettings *settings, gchar *key, CcDateTimePanel *panel) { CcDateTimePanelPrivate *priv = panel->priv; GtkWidget *format_combo; GDesktopClockFormat value; value = g_settings_get_enum (settings, CLOCK_FORMAT_KEY); priv->clock_format = value; format_combo = W ("format_combobox"); g_signal_handlers_block_by_func (format_combo, change_clock_settings, panel); if (value == G_DESKTOP_CLOCK_FORMAT_24H) gtk_combo_box_set_active_id (GTK_COMBO_BOX (format_combo), "24h"); else gtk_combo_box_set_active_id (GTK_COMBO_BOX (format_combo), "12h"); update_time (panel); g_signal_handlers_unblock_by_func (format_combo, change_clock_settings, panel); }
static void on_gsettings_changed_active (GSettings *settings, gchar *key, GtkWidget *widget) { GtkListStore *store; GSettingsSchemaSource *schema_source; GList *schema_list = NULL; gchar **non_relocatable; const gchar *id1; GtkTreeIter iter; gint i; id1 = gtk_combo_box_get_active_id (GTK_COMBO_BOX (widget)); store = (GtkListStore *) gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); gtk_list_store_clear (store); gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter); schema_source = g_settings_schema_source_get_default (); g_settings_schema_source_list_schemas (schema_source, TRUE, &non_relocatable, NULL); for (i = 0; non_relocatable[i] != NULL; i++) if (g_str_has_prefix (non_relocatable[i], "org.nimf.engines.")) schema_list = g_list_prepend (schema_list, non_relocatable[i]); for (schema_list = g_list_sort (schema_list, (GCompareFunc) on_comparison); schema_list != NULL; schema_list = schema_list->next) { GSettingsSchema *schema; GSettings *gsettings; gchar *name; const gchar *id2; schema = g_settings_schema_source_lookup (schema_source, schema_list->data, TRUE); gsettings = g_settings_new (schema_list->data); name = g_settings_get_string (gsettings, "hidden-schema-name"); id2 = schema_list->data + strlen ("org.nimf.engines."); if (g_settings_schema_has_key (schema, "active") == FALSE || g_settings_get_boolean (gsettings, "active")) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, name, 1, id2, -1); } g_settings_schema_unref (schema); g_free (name); g_object_unref (gsettings); } if (gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), id1) == FALSE) gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), "nimf-system-keyboard"); g_strfreev (non_relocatable); g_list_free (schema_list); }
static update_dates(gpointer data) { guint year = ((NEW_DATA *) data)->newrun->year; guint month = ((NEW_DATA *) data)->newrun->month; gchar month_str[3]; g_snprintf(month_str, 3, "%i", month); guint day = ((NEW_DATA *) data)->newrun->day; GtkCalendar *calendar = ((NEW_DATA*) data)->calendar; GtkSpinButton *day_chooser = ((NEW_DATA*) data)->day_chooser; GtkComboBoxText *month_chooser = ((NEW_DATA*) data)->month_chooser; GtkSpinButton *year_chooser = ((NEW_DATA*) data)->year_chooser; gtk_spin_button_set_value(GTK_SPIN_BUTTON(day_chooser), day); gtk_spin_button_update(day_chooser); gtk_combo_box_set_active_id(GTK_COMBO_BOX(month_chooser), month_str); gtk_spin_button_set_value(GTK_SPIN_BUTTON(year_chooser), year); gtk_spin_button_update(year_chooser); gtk_calendar_select_day(GTK_CALENDAR(calendar), day); gtk_calendar_select_month(GTK_CALENDAR(calendar), month, year); //printf("%i/%i/%i\n", month, day, year); }
static void icon_name_entry_activated (GtkEntry * entry, GladeEPropIconSources * eprop_sources) { const gchar *text = gtk_entry_get_text (entry); GladeProperty *property; GladeIconSources *sources = NULL; if (!text || !text[0]) return; property = glade_editor_property_get_property (GLADE_EDITOR_PROPERTY (eprop_sources)); if (!property) return; glade_property_get (property, &sources); if (sources == NULL || g_hash_table_lookup (sources->sources, text) == NULL) { /* Add the new source if it doesnt already exist */ gtk_combo_box_text_insert (GTK_COMBO_BOX_TEXT (eprop_sources->combo), -1, text, text); } /* Set the active id whether it existed or not */ gtk_combo_box_set_active_id (GTK_COMBO_BOX (eprop_sources->combo), text); }
static void html_editor_hrule_dialog_get_width (EHTMLEditorHRuleDialog *dialog) { gchar *width; const gchar *units; gint width_int = 0; g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element)); width = webkit_dom_htmlhr_element_get_width (dialog->priv->hr_element); if (width && *width) { width_int = atoi (width); if (strstr (width, "%") != NULL) { units = "units-percent"; } else { units = "units-px"; } } if (width_int == 0) { width_int = 100; units = "units-percent"; } gtk_spin_button_set_value ( GTK_SPIN_BUTTON (dialog->priv->width_edit), (gdouble) width_int); gtk_combo_box_set_active_id ( GTK_COMBO_BOX (dialog->priv->unit_combo), units); g_free (width); }
static GtkWidget * deserialize_choice (GVariant *choice, FileDialogHandle *handle) { GtkWidget *widget; const char *choice_id; const char *label; const char *selected; GVariant *choices; int i; g_variant_get (choice, "(&s&s@a(ss)&s)", &choice_id, &label, &choices, &selected); if (g_variant_n_children (choices) > 0) { GtkWidget *box; GtkWidget *combo; box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (box), gtk_label_new (label)); combo = gtk_combo_box_text_new (); g_object_set_data_full (G_OBJECT (combo), "choice-id", g_strdup (choice_id), g_free); gtk_container_add (GTK_CONTAINER (box), combo); for (i = 0; i < g_variant_n_children (choices); i++) { const char *id; const char *text; g_variant_get_child (choices, i, "(&s&s)", &id, &text); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), id, text); } if (strcmp (selected, "") == 0) g_variant_get_child (choices, 0, "(&s&s)", &selected, NULL); g_signal_connect (combo, "changed", G_CALLBACK (choice_changed), handle); gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), selected); widget = box; } else { GtkWidget *check; check = gtk_check_button_new_with_label (label); g_object_set_data_full (G_OBJECT (check), "choice-id", g_strdup (choice_id), g_free); g_signal_connect (check, "toggled", G_CALLBACK (choice_toggled), handle); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), g_strcmp0 (selected, "true") == 0); widget = check; } gtk_widget_show_all (widget); return widget; }
static void html_editor_hrule_dialog_get_alignment (EHTMLEditorHRuleDialog *dialog) { gchar *alignment; g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element)); alignment = webkit_dom_htmlhr_element_get_align (dialog->priv->hr_element); gtk_combo_box_set_active_id ( GTK_COMBO_BOX (dialog->priv->alignment_combo), alignment); g_free (alignment); }
void ttx_window_request_page (TTXWindow *self, TTXProviderID prov_id, unsigned page, unsigned subpage) { const char *combo_id; GtkComboBox *combo; const TTXProvider *prov; g_return_if_fail (TTX_IS_WINDOW(self)); g_return_if_fail (page >= 100 && page <= 999); g_return_if_fail (subpage > 0); if (page > 999 || subpage < 1) { g_warning ("invalid page %u/%u", page, subpage); update_entry (self); } /* if not provided, get the last one (or the default) */ if (!prov_id) prov_id = get_provider_id (self); if (prov_id) { prov = ttx_provider_mgr_get_provider ( self->priv->prov_mgr, prov_id); if (!prov) { g_printerr (_("unknown teletext provider %s\n"), prov_id); prov_id = "nos"; /* default */ } } combo = GTK_COMBO_BOX(self->priv->combo); combo_id = gtk_combo_box_get_active_id (combo); self->priv->retrieving = TRUE; if (g_strcmp0 (prov_id, combo_id) != 0) if (!gtk_combo_box_set_active_id (combo, prov_id)) g_warning ("failed to set active id to %s", prov_id); ttx_provider_mgr_retrieve (self->priv->prov_mgr, prov_id, page, subpage, (TTXProviderResultFunc)on_completed, self); }
static void on_gsettings_changed (GSettings *settings, gchar *key, GtkWidget *widget) { if (GTK_IS_SWITCH (widget)) { gboolean active1 = g_settings_get_boolean (settings, key); gboolean active2 = gtk_switch_get_active (GTK_SWITCH (widget)); if (active1 != active2) gtk_switch_set_active (GTK_SWITCH (widget), active1); } else if (GTK_IS_COMBO_BOX (widget)) { gchar *id; gboolean retval; id = g_settings_get_string (settings, key); retval = gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), id); if (retval == FALSE && g_strcmp0 (key, "default-engine") == 0) g_settings_set_string (settings, key, "nimf-system-keyboard"); g_free (id); } else if (GTK_IS_TREE_VIEW (widget)) { GtkTreeModel *model; gchar **vals; GtkTreeIter iter; gint i; vals = g_settings_get_strv (settings, key); model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); gtk_list_store_clear (GTK_LIST_STORE (model)); for (i = 0; vals[i] != NULL; i++) { gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, vals[i], -1); } g_strfreev (vals); } }
void addDropDownList(int numberOfElements, GtkGrid *grid, void (*entryChangedFuncPtr) (GtkComboBox *editable, gpointer), int col, int row){ GtkWidget* comboBoxWithText = gtk_combo_box_text_new_with_entry (); int i = 1; while(i <= numberOfElements){ char *numberAsChar = malloc(20); sprintf(numberAsChar, "%d", i); gtk_combo_box_text_append (comboBoxWithText, numberAsChar, numberAsChar); i = i + 1; } gtk_combo_box_set_active_id (comboBoxWithText,"1"); g_signal_connect(comboBoxWithText, "changed", G_CALLBACK(entryChangedFuncPtr), NULL); gtk_grid_attach(grid, comboBoxWithText, col, row, 1, 1); gtk_widget_show(comboBoxWithText); }
static void g_paste_settings_ui_stack_private_refill_histories (GPasteSettingsUiStackPrivate *priv) { G_PASTE_CLEANUP_ERROR_FREE GError *error = NULL; GStrv histories = g_paste_client_list_histories_sync (priv->client, &error); if (g_paste_settings_ui_check_connection_error (error)) return; GtkComboBoxText *targets = priv->targets; gtk_combo_box_text_remove_all (targets); for (guint i = 0; histories[i]; ++i) gtk_combo_box_text_append (targets, histories[i], histories[i]); gtk_combo_box_set_active_id (GTK_COMBO_BOX (targets), g_paste_settings_get_history_name (priv->settings)); }
static void fill_combo_box_with_children(GtkComboBox *box, SooshiNode *node) { GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(box)); GList *elem; SooshiNode *item; gint id = 0; for(elem = node->children; elem; elem = elem->next) { item = elem->data; GtkTreeIter iter; gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, item->name, 1, id, -1); id++; } gtk_combo_box_set_active_id(box, 0); }
static void cb_changed( GtkComboBox *combo, gpointer data ) { int i = 0; /* Obtain currently selected string from combo box */ gchar *string = gtk_combo_box_text_get_active_text( gender ); gtk_combo_box_set_active_id(gender, string); /* if( strcmp((char *)string, ht_str[i])); for(){ gtk_combo_box_set_active_id( } */ /* Print it to the console - if nothing is selected, print NULL */ g_print( "Selected (simple): >> %s <<\n", ( string ? string : "NULL" ) ); /* Free string */ g_free( string ); }
static void composer_load_signature_cb (EMailSignatureComboBox *combo_box, GAsyncResult *result, EMsgComposer *composer) { GString *html_buffer = NULL; gchar *contents = NULL; gsize length = 0; const gchar *active_id; gboolean top_signature, is_html, html_mode; gboolean start_bottom, is_message_from_edit_as_new; GError *error = NULL; EHTMLEditor *editor; EHTMLEditorView *view; WebKitDOMDocument *document; WebKitDOMElement *element = NULL; WebKitDOMNodeList *signatures; gulong list_length, ii; GSettings *settings; e_mail_signature_combo_box_load_selected_finish ( combo_box, result, &contents, &length, &is_html, &error); /* FIXME Use an EAlert here. */ if (error != NULL) { g_warning ("%s: %s", G_STRFUNC, error->message); g_error_free (error); goto exit; } if (composer->priv->ignore_next_signature_change) { composer->priv->ignore_next_signature_change = FALSE; goto exit; } editor = e_msg_composer_get_editor (composer); view = e_html_editor_get_view (editor); is_message_from_edit_as_new = e_html_editor_view_is_message_from_edit_as_new (view); /* "Edit as New Message" sets is_message_from_edit_as_new. * Always put the signature at the bottom for that case. */ top_signature = use_top_signature (composer) && !is_message_from_edit_as_new && !composer->priv->is_from_new_message; settings = e_util_ref_settings ("org.gnome.evolution.mail"); start_bottom = g_settings_get_boolean (settings, "composer-reply-start-bottom"); g_object_unref (settings); document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view)); html_mode = e_html_editor_view_get_html_mode (view); if (contents == NULL) goto insert; /* If inserting HTML signature in plain text composer we have to convert it. */ if (is_html && !html_mode) { WebKitDOMElement *tmp_element; gchar *inner_text; tmp_element = webkit_dom_document_create_element (document, "div", NULL); webkit_dom_html_element_set_inner_html ( WEBKIT_DOM_HTML_ELEMENT (tmp_element), contents, NULL); inner_text = webkit_dom_html_element_get_inner_text ( WEBKIT_DOM_HTML_ELEMENT (tmp_element)); g_free (contents); contents = inner_text ? g_strstrip (inner_text) : g_strdup (""); is_html = FALSE; } if (!is_html) { gchar *html; html = camel_text_to_html (contents, 0, 0); if (html) { g_free (contents); contents = html; length = strlen (contents); } } /* Generate HTML code for the signature. */ html_buffer = g_string_sized_new (1024); /* The combo box active ID is the signature's ESource UID. */ active_id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (combo_box)); g_string_append_printf ( html_buffer, "<SPAN class=\"-x-evo-signature\" id=\"1\" name=\"%s\">", (active_id != NULL) ? active_id : ""); if (!is_html) g_string_append (html_buffer, "<PRE>"); /* The signature dash convention ("-- \n") is specified * in the "Son of RFC 1036", section 4.3.2. * http://www.chemie.fu-berlin.de/outerspace/netnews/son-of-1036.html */ if (add_signature_delimiter (composer)) { const gchar *delim; const gchar *delim_nl; if (is_html) { delim = "-- <BR>"; delim_nl = "\n-- <BR>"; } else { delim = "-- \n"; delim_nl = "\n-- \n"; } /* Skip the delimiter if the signature already has one. */ if (g_ascii_strncasecmp (contents, delim, strlen (delim)) == 0) ; /* skip */ else if (e_util_strstrcase (contents, delim_nl) != NULL) ; /* skip */ else g_string_append (html_buffer, delim); } g_string_append_len (html_buffer, contents, length); if (!is_html) g_string_append (html_buffer, "</PRE>"); g_string_append (html_buffer, "</SPAN>"); g_free (contents); insert: /* Remove the old signature and insert the new one. */ signatures = webkit_dom_document_get_elements_by_class_name ( document, "-x-evo-signature-wrapper"); list_length = webkit_dom_node_list_get_length (signatures); for (ii = 0; ii < list_length; ii++) { WebKitDOMNode *wrapper, *signature; gchar *id; wrapper = webkit_dom_node_list_item (signatures, ii); signature = webkit_dom_node_get_first_child (wrapper); /* When we are editing a message with signature, we need to unset the * active signature id as if the signature in the message was edited * by the user we would discard these changes. */ if (composer->priv->set_signature_from_message && (is_message_from_edit_as_new || e_html_editor_view_is_message_from_draft (view))) { if (composer->priv->check_if_signature_is_changed) { if (html_buffer && *html_buffer->str) { gchar *body_signature_text, *signature_text; element = webkit_dom_document_create_element (document, "div", NULL); webkit_dom_html_element_set_inner_html ( WEBKIT_DOM_HTML_ELEMENT (element), html_buffer->str, NULL); body_signature_text = webkit_dom_html_element_get_inner_text ( WEBKIT_DOM_HTML_ELEMENT (signature)); signature_text = webkit_dom_html_element_get_inner_text ( WEBKIT_DOM_HTML_ELEMENT (element)); /* Signature in the body is different than the one with the * same id, so set the active signature to None and leave * the signature that is in the body. */ if (g_strcmp0 (body_signature_text, signature_text) != 0) { gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0); composer->priv->ignore_next_signature_change = TRUE; } g_free (body_signature_text); g_free (signature_text); } else { gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0); composer->priv->ignore_next_signature_change = TRUE; } composer->priv->check_if_signature_is_changed = FALSE; composer->priv->set_signature_from_message = FALSE; } else { gchar *name; /* Load the signature and check if is it the same * as the signature in body or the user previously * changed it. */ name = webkit_dom_element_get_attribute (WEBKIT_DOM_ELEMENT (signature), "name"); gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), name); g_free (name); composer->priv->check_if_signature_is_changed = TRUE; } g_object_unref (wrapper); g_object_unref (signatures); g_object_unref (composer); return; } id = webkit_dom_element_get_id (WEBKIT_DOM_ELEMENT (signature)); if (id && (strlen (id) == 1) && (*id == '1')) { /* If the top signature was set we have to remove the NL * that was inserted after it */ if (top_signature) { WebKitDOMElement *spacer; spacer = webkit_dom_document_query_selector ( document, ".-x-evo-top-signature-spacer", NULL); if (spacer) remove_node_if_empty (WEBKIT_DOM_NODE (spacer)); } /* We have to remove the div containing the span with signature */ remove_node (wrapper); g_object_unref (wrapper); g_free (id); break; } g_object_unref (wrapper); g_free (id); } g_object_unref (signatures); if (html_buffer != NULL) { if (*html_buffer->str) { WebKitDOMHTMLElement *body; body = webkit_dom_document_get_body (document); if (!element) { element = webkit_dom_document_create_element (document, "DIV", NULL); webkit_dom_html_element_set_inner_html ( WEBKIT_DOM_HTML_ELEMENT (element), html_buffer->str, NULL); } webkit_dom_element_set_class_name (element, "-x-evo-signature-wrapper"); if (top_signature) { WebKitDOMNode *child = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)); if (start_bottom) { webkit_dom_node_insert_before ( WEBKIT_DOM_NODE (body), WEBKIT_DOM_NODE (element), child, NULL); } else { /* When we are using signature on top the caret * should be before the signature */ webkit_dom_node_insert_before ( WEBKIT_DOM_NODE (body), WEBKIT_DOM_NODE (element), child, NULL); } } else { webkit_dom_node_append_child ( WEBKIT_DOM_NODE (body), WEBKIT_DOM_NODE (element), NULL); } } g_string_free (html_buffer, TRUE); } if (is_html && html_mode) e_html_editor_view_fix_file_uri_images (view); composer_move_caret (composer); exit: /* Make sure the flag will be unset and won't influence user's choice */ composer->priv->set_signature_from_message = FALSE; g_object_unref (composer); }
static GtkWidget * nimf_settings_page_key_build_string (NimfSettingsPageKey *page_key, const gchar *schema_id, GList *key_list) { GtkListStore *store; GtkWidget *combo; GtkWidget *hbox; gchar *detailed_signal; GtkTreeIter iter; store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); combo = gtk_combo_box_text_new (); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store)); g_object_unref (store); gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), 1); gtk_tree_model_get_iter_first ((GtkTreeModel *) store, &iter); if (g_strcmp0 (schema_id, "org.nimf.engines") == 0 && g_strcmp0 (page_key->key, "default-engine") == 0) { GSettingsSchemaSource *schema_source; GList *schema_list = NULL; gchar **non_relocatable; gchar *id1; gint i; id1 = g_settings_get_string (page_key->gsettings, page_key->key); schema_source = g_settings_schema_source_get_default (); g_settings_schema_source_list_schemas (schema_source, TRUE, &non_relocatable, NULL); for (i = 0; non_relocatable[i] != NULL; i++) if (g_str_has_prefix (non_relocatable[i], "org.nimf.engines.")) schema_list = g_list_prepend (schema_list, non_relocatable[i]); for (schema_list = g_list_sort (schema_list, (GCompareFunc) on_comparison); schema_list != NULL; schema_list = schema_list->next) { GSettingsSchema *schema; GSettings *gsettings; gchar *name; const gchar *id2; schema = g_settings_schema_source_lookup (schema_source, schema_list->data, TRUE); gsettings = g_settings_new (schema_list->data); name = g_settings_get_string (gsettings, "hidden-schema-name"); id2 = schema_list->data + strlen ("org.nimf.engines."); if (g_settings_schema_has_key (schema, "active") == FALSE || g_settings_get_boolean (gsettings, "active")) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, name, 1, id2, -1); } if (g_settings_schema_has_key (schema, "active")) g_signal_connect (gsettings, "changed::active", G_CALLBACK (on_gsettings_changed_active), combo); g_settings_schema_unref (schema); g_free (name); /*g_object_unref (gsettings);*/ /*** FIXME ***/ } if (gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), id1) == FALSE) { g_settings_set_string (page_key->gsettings, "default-engine", "nimf-system-keyboard"); gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), "nimf-system-keyboard"); } g_strfreev (non_relocatable); g_list_free (schema_list); g_free (id1); } else if (g_str_has_prefix (page_key->key, "hidden-") == FALSE) { gchar *id1; GList *list; id1 = g_settings_get_string (page_key->gsettings, page_key->key); for (list = key_list; list != NULL; list = list->next) { gchar *key2; gchar *prefix; key2 = list->data; prefix = g_strdup_printf ("hidden-%s-", page_key->key); if (g_str_has_prefix (key2, prefix)) { gchar *val; const gchar *id2 = key2 + strlen (prefix); val = g_settings_get_string (page_key->gsettings, key2); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, val, 1, id2, -1); if (g_strcmp0 (id1, id2) == 0) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter); g_free (val); } g_free (prefix); } g_free (id1); } hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 15); gtk_box_pack_start (GTK_BOX (hbox), page_key->label, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), combo, FALSE, FALSE, 0); detailed_signal = g_strdup_printf ("changed::%s", page_key->key); g_signal_connect (combo, "changed", G_CALLBACK (on_combo_box_changed), page_key); g_signal_connect (page_key->gsettings, detailed_signal, G_CALLBACK (on_gsettings_changed), combo); g_free (detailed_signal); return hbox; }
static void pattern_label_update (void) { char *file_pattern, *path_pattern; char *file_value, *path_value, *example, *format; char *media_type; GstEncodingProfile *profile; /* Disable -Wdiscarded-quantifiers to prevent warnings as we're initalizing gchar* from const gchar*. This is safe as the strings are never changed. */ SJ_BEGIN_IGNORE_DISCARDED_QUANTIFIERS static const AlbumDetails sample_album = { .title = "Help!", /* title */ .artist = "The Beatles", /* artist */ .artist_sortname = "Beatles, The", /* artist_sortname */ .genre = NULL, /* genre */ .number = 0, /* number of tracks*/ .disc_number = 1, /* disc number */ .tracks = NULL, /* track list */ .release_date = NULL, /* release date */ .album_id = NULL, /* album ID */ .artist_id = NULL /* artist ID */ }; static const TrackDetails sample_track = { .album = (AlbumDetails*)&sample_album, /*album */ .number = 7, /* track number */ .title = "Ticket To Ride", /* title */ .artist = "The Beatles", /* artist */ .artist_sortname = "Beatles, The", /* artist_sortname */ .composer = "John Lennon and Paul McCartney", /* composer */ .composer_sortname = "Lennon, John", /* composer_sortname */ .duration = 0, /* duration */ .track_id = NULL, /* track ID */ .artist_id = NULL, /* artist ID */ }; SJ_END_IGNORE_DISCARDED_QUANTIFIERS g_object_get (sj_extractor, "profile", &profile, NULL); /* It's possible the profile isn't set, in which case do nothing */ if (!profile) { return; } media_type = rb_gst_encoding_profile_get_media_type (profile); gst_encoding_profile_unref (profile); /* TODO: sucky. Replace with get-gconf-key-with-default mojo */ file_pattern = g_settings_get_string (sj_settings, SJ_SETTINGS_FILE_PATTERN); if (file_pattern == NULL) { file_pattern = g_strdup (sj_get_default_file_pattern ()); } path_pattern = g_settings_get_string (sj_settings, SJ_SETTINGS_PATH_PATTERN); if (path_pattern == NULL) { path_pattern = g_strdup (sj_get_default_path_pattern ()); } file_value = filepath_parse_pattern (file_pattern, &sample_track); path_value = filepath_parse_pattern (path_pattern, &sample_track); example = g_build_filename (G_DIR_SEPARATOR_S, path_value, file_value, NULL); g_free (file_value); g_free (file_pattern); g_free (path_value); g_free (path_pattern); format = g_strconcat ("<small><i><b>", _("Example Path: "), "</b>", example, ".", rb_gst_media_type_to_extension (media_type), "</i></small>", NULL); g_free (example); g_free (media_type); gtk_label_set_markup (GTK_LABEL (path_example_label), format); g_free (format); } static void settings_changed_cb (GSettings *settings, const gchar *key, gpointer combo) { char *value; value = g_settings_get_string (settings, key); if (!gtk_combo_box_set_active_id (combo, value)) gtk_combo_box_set_active_id (combo, NULL); g_free (value); pattern_label_update (); } /** * Default device changed (either GSettings key or the widget) */ static void device_changed_cb (GSettings *settings, const gchar *key, gpointer user_data) { BraseroDrive *drive; BraseroMediumMonitor *monitor; char *value; g_return_if_fail (strcmp (key, SJ_SETTINGS_DEVICE) == 0); value = g_settings_get_string (settings, key); if ((value != NULL) && (*value != '\0')) { monitor = brasero_medium_monitor_get_default (); drive = brasero_medium_monitor_get_drive (monitor, value); brasero_drive_selection_set_active (BRASERO_DRIVE_SELECTION (cd_option), drive); g_object_unref (drive); g_object_unref (monitor); } else { /* FIXME: see the FIXME in sj-main.c around one of the * device_changed_cb calls for a way to fix this */ g_warn_if_reached(); } g_free (value); }
gint main (gint argc, gchar * argv[]) { LocalState state; GtkWidget *area, *combo, *w; const gchar *uri; XInitThreads (); gst_init (&argc, &argv); gtk_init (&argc, &argv); if (argc < 2) { g_print ("Usage: 3dvideo <uri-to-play>\n"); return 1; } uri = argv[1]; GstElement *pipeline = gst_element_factory_make ("playbin", NULL); GstBin *sinkbin = (GstBin *) gst_parse_bin_from_description ("glupload ! glcolorconvert ! glviewconvert name=viewconvert ! glimagesink name=sink", TRUE, NULL); #if USE_GLCONVERT_FOR_INPUT GstElement *glconvert = gst_bin_get_by_name (sinkbin, "viewconvert"); #endif GstElement *videosink = gst_bin_get_by_name (sinkbin, "sink"); /* Get defaults */ g_object_get (pipeline, "video-multiview-mode", &state.in_mode, "video-multiview-flags", &state.in_flags, NULL); gst_child_proxy_get (GST_CHILD_PROXY (videosink), "sink::output-multiview-mode", &state.out_mode, "sink::output-multiview-flags", &state.out_flags, NULL); detect_mode_from_uri (&state, uri); g_return_val_if_fail (pipeline != NULL, 1); g_return_val_if_fail (videosink != NULL, 1); g_object_set (G_OBJECT (pipeline), "video-sink", sinkbin, NULL); g_object_set (G_OBJECT (pipeline), "uri", uri, NULL); #if USE_GLCONVERT_FOR_INPUT g_object_set (G_OBJECT (glconvert), "input-mode-override", state.in_mode, NULL); g_object_set (G_OBJECT (glconvert), "input-flags-override", state.in_flags, NULL); #else g_object_set (G_OBJECT (pipeline), "video-multiview-mode", state.in_mode, NULL); g_object_set (G_OBJECT (pipeline), "video-multiview-flags", state.in_flags, NULL); #endif /* Connect to bus for signal handling */ GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), pipeline); g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), pipeline); g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), pipeline); gst_element_set_state (pipeline, GST_STATE_READY); area = gtk_drawing_area_new (); gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, area, NULL); gst_object_unref (bus); /* Toplevel window */ GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); gtk_window_set_title (GTK_WINDOW (window), "Stereoscopic video demo"); GdkGeometry geometry; geometry.min_width = 1; geometry.min_height = 1; geometry.max_width = -1; geometry.max_height = -1; gtk_window_set_geometry_hints (GTK_WINDOW (window), window, &geometry, GDK_HINT_MIN_SIZE); GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_add (GTK_CONTAINER (window), vbox); /* area where the video is drawn */ gtk_box_pack_start (GTK_BOX (vbox), area, TRUE, TRUE, 0); /* Buttons to control the pipeline state */ GtkWidget *table = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (vbox), table); GtkWidget *button_state_ready = gtk_button_new_with_label ("Stop"); g_signal_connect (G_OBJECT (button_state_ready), "clicked", G_CALLBACK (button_state_ready_cb), pipeline); gtk_grid_attach (GTK_GRID (table), button_state_ready, 1, 0, 1, 1); gtk_widget_show (button_state_ready); //control state paused GtkWidget *button_state_paused = gtk_button_new_with_label ("Pause"); g_signal_connect (G_OBJECT (button_state_paused), "clicked", G_CALLBACK (button_state_paused_cb), pipeline); gtk_grid_attach (GTK_GRID (table), button_state_paused, 2, 0, 1, 1); gtk_widget_show (button_state_paused); //control state playing GtkWidget *button_state_playing = gtk_button_new_with_label ("Play"); g_signal_connect (G_OBJECT (button_state_playing), "clicked", G_CALLBACK (button_state_playing_cb), pipeline); gtk_grid_attach (GTK_GRID (table), button_state_playing, 3, 0, 1, 1); //gtk_widget_show (button_state_playing); w = gst_mview_widget_new (FALSE); combo = GST_MVIEW_WIDGET (w)->mode_selector; gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), enum_value_to_nick (GST_TYPE_VIDEO_MULTIVIEW_FRAME_PACKING, state.in_mode)); #if USE_GLCONVERT_FOR_INPUT g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (set_mview_input_mode), glconvert); #else g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (set_mview_input_mode), pipeline); #endif g_object_set (G_OBJECT (w), "flags", state.in_flags, NULL); #if USE_GLCONVERT_FOR_INPUT g_signal_connect (G_OBJECT (w), "notify::flags", G_CALLBACK (input_flags_changed), glconvert); #else g_signal_connect (G_OBJECT (w), "notify::flags", G_CALLBACK (input_flags_changed), pipeline); #endif gtk_container_add (GTK_CONTAINER (vbox), w); w = gst_mview_widget_new (TRUE); combo = GST_MVIEW_WIDGET (w)->mode_selector; gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), enum_value_to_nick (GST_TYPE_VIDEO_MULTIVIEW_MODE, state.out_mode)); g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (set_mview_output_mode), videosink); g_object_set (G_OBJECT (w), "flags", state.out_flags, NULL); g_signal_connect (G_OBJECT (w), "notify::flags", G_CALLBACK (output_flags_changed), videosink); g_signal_connect (G_OBJECT (w), "notify::downmix-mode", G_CALLBACK (downmix_method_changed), videosink); gtk_container_add (GTK_CONTAINER (vbox), w); //configure the pipeline g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (destroy_cb), pipeline); gtk_widget_realize (area); /* Redraw needed when paused or stopped (PAUSED or READY) */ g_signal_connect (area, "draw", G_CALLBACK (draw_cb), videosink); g_signal_connect(area, "configure-event", G_CALLBACK(resize_cb), videosink); gtk_widget_show_all (window); gst_element_set_state (pipeline, GST_STATE_PLAYING); gtk_main (); return 0; }
static void html_editor_hrule_dialog_show (GtkWidget *widget) { EHTMLEditorHRuleDialog *dialog; EHTMLEditor *editor; EHTMLEditorSelection *selection; EHTMLEditorView *view; WebKitDOMDocument *document; dialog = E_HTML_EDITOR_HRULE_DIALOG (widget); editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog)); view = e_html_editor_get_view (editor); selection = e_html_editor_view_get_selection (view); if (!e_html_editor_view_is_undo_redo_in_progress (view)) { EHTMLEditorViewHistoryEvent *ev; ev = g_new0 (EHTMLEditorViewHistoryEvent, 1); ev->type = HISTORY_HRULE_DIALOG; e_html_editor_selection_get_selection_coordinates ( selection, &ev->before.start.x, &ev->before.start.y, &ev->before.end.x, &ev->before.end.y); if (dialog->priv->hr_element) ev->data.dom.from = webkit_dom_node_clone_node ( WEBKIT_DOM_NODE (dialog->priv->hr_element), FALSE); else ev->data.dom.from = NULL; dialog->priv->history_event = ev; } if (!dialog->priv->hr_element) { WebKitDOMElement *selection_start, *parent, *rule; document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view)); e_html_editor_selection_save (selection); selection_start = webkit_dom_document_get_element_by_id ( document, "-x-evo-selection-start-marker"); parent = get_parent_block_element (WEBKIT_DOM_NODE (selection_start)); rule = webkit_dom_document_create_element (document, "HR", NULL); /* Insert horizontal rule into body below the caret */ webkit_dom_node_insert_before ( webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (parent)), WEBKIT_DOM_NODE (rule), webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (parent)), NULL); e_html_editor_selection_restore (selection); dialog->priv->hr_element = WEBKIT_DOM_HTMLHR_ELEMENT (rule); /* For new rule reset the values to default */ gtk_spin_button_set_value ( GTK_SPIN_BUTTON (dialog->priv->width_edit), 100.0); gtk_combo_box_set_active_id ( GTK_COMBO_BOX (dialog->priv->unit_combo), "units-percent"); gtk_spin_button_set_value ( GTK_SPIN_BUTTON (dialog->priv->size_edit), 2.0); gtk_combo_box_set_active_id ( GTK_COMBO_BOX (dialog->priv->alignment_combo), "left"); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (dialog->priv->shaded_check), FALSE); html_editor_hrule_dialog_set_alignment (dialog); html_editor_hrule_dialog_set_size (dialog); html_editor_hrule_dialog_set_alignment (dialog); html_editor_hrule_dialog_set_shading (dialog); e_html_editor_view_set_changed (view, TRUE); } else { html_editor_hrule_dialog_get_alignment (dialog); html_editor_hrule_dialog_get_size (dialog); html_editor_hrule_dialog_get_width (dialog); html_editor_hrule_dialog_get_shading (dialog); } /* Chain up to parent implementation */ GTK_WIDGET_CLASS (e_html_editor_hrule_dialog_parent_class)->show (widget); }
static void html_editor_image_dialog_show (GtkWidget *widget) { EHTMLEditorImageDialog *dialog; EHTMLEditor *editor; EHTMLEditorSelection *selection; EHTMLEditorView *view; WebKitDOMElement *link; gchar *tmp; glong val; dialog = E_HTML_EDITOR_IMAGE_DIALOG (widget); if (!dialog->priv->image) { return; } editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog)); view = e_html_editor_get_view (editor); selection = e_html_editor_view_get_selection (view); if (!e_html_editor_view_is_undo_redo_in_progress (view)) { EHTMLEditorViewHistoryEvent *ev; ev = g_new0 (EHTMLEditorViewHistoryEvent, 1); ev->type = HISTORY_IMAGE_DIALOG; e_html_editor_selection_get_selection_coordinates ( selection, &ev->before.start.x, &ev->before.start.y, &ev->before.end.x, &ev->before.end.y); ev->data.dom.from = webkit_dom_node_clone_node ( WEBKIT_DOM_NODE (dialog->priv->image), FALSE); dialog->priv->history_event = ev; } tmp = webkit_dom_element_get_attribute ( WEBKIT_DOM_ELEMENT (dialog->priv->image), "data-uri"); if (tmp && *tmp) { gtk_file_chooser_set_uri ( GTK_FILE_CHOOSER (dialog->priv->file_chooser), tmp); gtk_widget_set_sensitive ( GTK_WIDGET (dialog->priv->file_chooser), TRUE); } else { gtk_file_chooser_set_uri ( GTK_FILE_CHOOSER (dialog->priv->file_chooser), ""); gtk_widget_set_sensitive ( GTK_WIDGET (dialog->priv->file_chooser), FALSE); } g_free (tmp); tmp = webkit_dom_html_image_element_get_alt (dialog->priv->image); gtk_entry_set_text (GTK_ENTRY (dialog->priv->description_edit), tmp ? tmp : ""); g_free (tmp); val = webkit_dom_html_image_element_get_width (dialog->priv->image); gtk_spin_button_set_value ( GTK_SPIN_BUTTON (dialog->priv->width_edit), val); gtk_combo_box_set_active_id ( GTK_COMBO_BOX (dialog->priv->width_units), "units-px"); val = webkit_dom_html_image_element_get_height (dialog->priv->image); gtk_spin_button_set_value ( GTK_SPIN_BUTTON (dialog->priv->height_edit), val); gtk_combo_box_set_active_id ( GTK_COMBO_BOX (dialog->priv->height_units), "units-px"); tmp = webkit_dom_html_image_element_get_border (dialog->priv->image); gtk_combo_box_set_active_id ( GTK_COMBO_BOX (dialog->priv->alignment), (tmp && *tmp) ? tmp : "bottom"); g_free (tmp); val = webkit_dom_html_image_element_get_hspace (dialog->priv->image); gtk_spin_button_set_value ( GTK_SPIN_BUTTON (dialog->priv->x_padding_edit), val); val = webkit_dom_html_image_element_get_vspace (dialog->priv->image); gtk_spin_button_set_value ( GTK_SPIN_BUTTON (dialog->priv->y_padding_edit), val); link = e_html_editor_dom_node_find_parent_element ( WEBKIT_DOM_NODE (dialog->priv->image), "A"); if (link) { tmp = webkit_dom_html_anchor_element_get_href ( WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link)); gtk_entry_set_text (GTK_ENTRY (dialog->priv->url_edit), tmp); g_free (tmp); } /* Chain up to parent implementation */ GTK_WIDGET_CLASS (e_html_editor_image_dialog_parent_class)->show (widget); }
void init_newrun_window_for_edit(GtkWidget *widget, gpointer data) { NEW_DATA *new_data = (NEW_DATA *) data; populate_MRUs(new_data); GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; GValue value = G_VALUE_INIT; gchar buff[30]; gchar seconds_buff[3]; gchar minutes_buff[3]; gchar hours_buff[3]; selection = gtk_tree_view_get_selection(new_data->runlist); gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); gtk_tree_selection_get_selected(selection, &model, &iter); gtk_tree_model_get_value(model, &iter, INDEX, &value); new_data->edit_index = g_value_get_int(&value); // set the date set_time_strings(new_data->database->run[new_data->edit_index]->duration, hours_buff, minutes_buff, seconds_buff); gtk_spin_button_set_value(GTK_SPIN_BUTTON(new_data->day_chooser), new_data->database->run[new_data->edit_index]->day); g_snprintf(buff, 30, "%i", new_data->database->run[new_data->edit_index]->month); gtk_combo_box_set_active_id(GTK_COMBO_BOX(new_data->month_chooser), buff); gtk_spin_button_set_value(GTK_SPIN_BUTTON(new_data->year_chooser), new_data->database->run[new_data->edit_index]->year); // setting the distance gtk_spin_button_set_value(GTK_SPIN_BUTTON(new_data->distance_chooser), new_data->database->run[new_data->edit_index]->distance); // setting the time fields gtk_entry_buffer_set_text(new_data->seconds_buff, seconds_buff, 2); gtk_entry_buffer_set_text(new_data->minutes_buff, minutes_buff, 2); gtk_entry_buffer_set_text(new_data->hours_buff, hours_buff, 2); // setting the entries GtkWidget *entry = gtk_bin_get_child(GTK_BIN(new_data->route_entry)); gtk_entry_set_text(GTK_ENTRY(entry), new_data->database->run[new_data->edit_index]->route); entry = gtk_bin_get_child(GTK_BIN(new_data->workout_type_entry)); gtk_entry_set_text(GTK_ENTRY(entry), new_data->database->run[new_data->edit_index]->type); // setting the feel button active switch (new_data->database->run[new_data->edit_index]->feel) { case 1: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_data->feel1), true); break; case 2: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_data->feel2), true); break; case 3: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_data->feel3), true); break; case 4: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_data->feel4), true); break; case 5: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_data->feel5), true); break; } // setting the time of day button active switch (new_data->database->run[new_data->edit_index]->time) { case 1: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_data->time1), true); break; case 2: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_data->time2), true); break; case 3: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_data->time3), true); break; case 4: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_data->time4), true); break; } //clearing the notes buffer gtk_text_buffer_set_text(new_data->notes_buff, new_data->database->run[new_data->edit_index]->notes, new_data->database->run[new_data->edit_index]->notes_len); open_window(GTK_WIDGET(widget), (gpointer) new_data->newrun_window); }
static void populate_store_foreach (const gchar * icon_name, GList * sources, GladeEPropIconSources * eprop_sources) { GtkIconSource *source; GtkTreeIter parent_iter, iter; GList *l; /* Update the comboboxentry's store here... */ gtk_combo_box_text_insert (GTK_COMBO_BOX_TEXT (eprop_sources->combo), -1, icon_name, icon_name); gtk_combo_box_set_active_id (GTK_COMBO_BOX (eprop_sources->combo), icon_name); /* Dont set COLUMN_ICON_NAME here */ gtk_tree_store_append (eprop_sources->store, &parent_iter, NULL); gtk_tree_store_set (eprop_sources->store, &parent_iter, COLUMN_TEXT, icon_name, COLUMN_TEXT_EDITABLE, FALSE, COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_BOLD, -1); for (l = sources; l; l = l->next) { GdkPixbuf *pixbuf; gchar *str; source = l->data; pixbuf = gtk_icon_source_get_pixbuf (source); str = g_object_get_data (G_OBJECT (pixbuf), "GladeFileName"); gtk_tree_store_append (eprop_sources->store, &iter, &parent_iter); gtk_tree_store_set (eprop_sources->store, &iter, COLUMN_ICON_NAME, icon_name, COLUMN_LIST_INDEX, g_list_index (sources, source), COLUMN_TEXT, str, COLUMN_TEXT_EDITABLE, TRUE, COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_NORMAL, -1); if (!gtk_icon_source_get_direction_wildcarded (source)) { GtkTextDirection direction = gtk_icon_source_get_direction (source); str = glade_utils_enum_string_from_value_displayable (GTK_TYPE_TEXT_DIRECTION, direction); gtk_tree_store_set (eprop_sources->store, &iter, COLUMN_DIRECTION_ACTIVE, TRUE, COLUMN_DIRECTION, str, -1); g_free (str); } if (!gtk_icon_source_get_size_wildcarded (source)) { GtkIconSize size = gtk_icon_source_get_size (source); str = glade_utils_enum_string_from_value_displayable (GTK_TYPE_ICON_SIZE, size); gtk_tree_store_set (eprop_sources->store, &iter, COLUMN_SIZE_ACTIVE, TRUE, COLUMN_SIZE, str, -1); g_free (str); } if (!gtk_icon_source_get_state_wildcarded (source)) { GtkStateType state = gtk_icon_source_get_state (source); str = glade_utils_enum_string_from_value_displayable (GTK_TYPE_STATE_TYPE, state); gtk_tree_store_set (eprop_sources->store, &iter, COLUMN_STATE_ACTIVE, TRUE, COLUMN_STATE, str, -1); g_free (str); } if (!l->next) { GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_sources->store), &iter); gtk_tree_view_expand_to_path (GTK_TREE_VIEW (eprop_sources->view), path); gtk_tree_path_free (path); } } }