GtkWidget *plugme_ui_add_config_file_menu_item(const gchar *real_path, const gchar *label, GtkContainer *parent) { GtkWidget *item; if (!parent) { item = ui_lookup_widget(geany->main_widgets->window, "configuration_files1"); parent = GTK_CONTAINER(gtk_menu_item_get_submenu(GTK_MENU_ITEM(item))); } if (!label) { gchar *base_name; base_name = g_path_get_basename(real_path); item = gtk_menu_item_new_with_label(base_name); g_free(base_name); } else item = gtk_menu_item_new_with_mnemonic(label); gtk_widget_show(item); gtk_container_add(parent, item); g_signal_connect_data(item, "activate", G_CALLBACK(on_config_file_clicked), g_strdup(real_path), free_on_closure_notify, 0); return item; }
static void bind_builder_radio (GtkBuilder *builder, GSettings *settings, const char **widget_names, const char *prefs, const char **values) { GtkWidget *button; int i; char *detailed_signal; RadioBinding *binding; detailed_signal = g_strdup_printf ("changed::%s", prefs); for (i = 0; widget_names[i] != NULL; i++) { button = GTK_WIDGET (gtk_builder_get_object (builder, widget_names[i])); binding = g_new (RadioBinding, 1); binding->button = button; binding->value = values[i]; binding->key = prefs; binding->settings = g_object_ref (settings); g_signal_connect (settings, detailed_signal, G_CALLBACK(radio_binding_setting_changed), binding); g_signal_connect_data (G_OBJECT (button), "toggled", G_CALLBACK (radio_binding_button_toggled), binding, free_radio_binding, 0); } }
unsigned int GConnection::unmanaged_connect_impl(GObject *object, const char *signal, GCallback callback, Slot *slot) { slot->ref(); slot->sink(); return g_signal_connect_data(object, signal, callback, slot, free_slot_closure, G_CONNECT_AFTER); }
static void show_wireless_dialog (GtkWidget *toplevel, NMClient *client, GtkWidget *dialog) { WirelessDialogClosure *closure; g_debug ("About to parent and show a network dialog"); g_assert (gtk_widget_is_toplevel (toplevel)); g_object_set (G_OBJECT (dialog), "modal", TRUE, "transient-for", toplevel, NULL); closure = g_slice_new (WirelessDialogClosure); closure->client = g_object_ref (client); g_signal_connect_data (dialog, "response", G_CALLBACK (wireless_dialog_response_cb), closure, wireless_dialog_closure_closure_notify, 0); g_object_bind_property (G_OBJECT (toplevel), "visible", G_OBJECT (dialog), "visible", G_BINDING_SYNC_CREATE); }
static GtkWidget * panel_menu_item_volume_new (GVolume *volume) { GtkWidget *item; GIcon *icon; char *title; char *tooltip; icon = g_volume_get_icon (volume); title = g_volume_get_name (volume); item = panel_image_menu_item_new (); setup_menu_item_with_icon (item, panel_menu_icon_get_size (), NULL, NULL, icon, title); g_object_unref (icon); tooltip = g_strdup_printf (_("Mount %s"), title); panel_util_set_tooltip_text (item, tooltip); g_free (tooltip); g_free (title); g_signal_connect_data (item, "activate", G_CALLBACK (panel_menu_item_mount_volume), g_object_ref (volume), (GClosureNotify) g_object_unref, 0); g_signal_connect (G_OBJECT (item), "button_press_event", G_CALLBACK (menu_dummy_button_press_event), NULL); return item; }
static GtkWidget * panel_menu_item_uri_new (const char *uri, const char *icon_name, GIcon *gicon, const char *title, const char *tooltip, GCallback callback) { GtkWidget *item; char *user_data; item = panel_image_menu_item_new (); setup_menu_item_with_icon (item, panel_menu_icon_get_size (), icon_name, NULL, gicon, title); panel_util_set_tooltip_text (item, tooltip); user_data = g_strdup (uri); g_signal_connect_data (item, "activate", callback, user_data, (GClosureNotify) g_free, 0); g_signal_connect (G_OBJECT (item), "button_press_event", G_CALLBACK (menu_dummy_button_press_event), NULL); setup_uri_drag (item, uri, icon_name); return item; }
GtkWidget * aw_popup_dialog_append (AwPopupDialog *dialog, const char *title, const char *details, AwPopupDialogCallback callback, gpointer user_data) { GtkWidget *button, *content_area; GClosure *closure; g_return_val_if_fail (AW_IS_POPUP_DIALOG (dialog), NULL); button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL, title, details); closure = g_cclosure_new (G_CALLBACK (callback), user_data, NULL); g_closure_set_marshal (closure, aw_cclosure_marshal_BOOLEAN__VOID); g_signal_connect_data (button, "clicked", G_CALLBACK (aw_popup_dialog_clicked_cb), closure, (GClosureNotify) g_closure_unref, 0); content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); gtk_container_add (GTK_CONTAINER (content_area), button); gtk_widget_show (button); return button; }
static NemoWindow * create_window (NemoApplication *application, GdkScreen *screen) { NemoWindow *window; g_return_val_if_fail (NEMO_IS_APPLICATION (application), NULL); window = g_object_new (NEMO_TYPE_WINDOW, "screen", screen, NULL); g_signal_connect_data (window, "delete_event", G_CALLBACK (nemo_window_delete_event_callback), NULL, NULL, G_CONNECT_AFTER); gtk_application_add_window (GTK_APPLICATION (application), GTK_WINDOW (window)); /* Do not yet show the window. It will be shown later on if it can * successfully display its initial URI. Otherwise it will be destroyed * without ever having seen the light of day. */ return window; }
//core theme class functions Boolean MCNativeTheme::load() { static Boolean initialised = False; if (!MCscreen -> hasfeature(PLATFORM_FEATURE_NATIVE_THEMES)) return false; if (!initialised) { gtk_init(); initialised = True; GtkSettings *settings = gtk_settings_get_default(); if (settings) g_signal_connect_data( settings, "notify::gtk-theme-name", G_CALLBACK(reload_theme), NULL, NULL, (GConnectFlags)0); } gtkpix = NULL; mNeedNewGC = true; if (MCscreen) { MCColor tbackcolor; moz_gtk_get_widget_color(GTK_STATE_NORMAL, tbackcolor.red,tbackcolor.green,tbackcolor.blue) ; MCscreen->background_pixel = tbackcolor;//tcolor = zcolor; // MW-2012-01-27: [[ Bug 9511 ]] Set the hilite color based on the current GTK theme. MCColor thilitecolor; moz_gtk_get_widget_color(GTK_STATE_SELECTED, thilitecolor.red, thilitecolor.green, thilitecolor.blue); MChilitecolor = thilitecolor; } return true; }
static void panel_menu_item_append_drive (GtkWidget *menu, GDrive *drive) { GtkWidget *item; GIcon *icon; char *title; char *tooltip; icon = g_drive_get_icon (drive); title = g_drive_get_name (drive); item = gtk_image_menu_item_new (); setup_menu_item_with_icon (item, panel_menu_icon_get_size (), NULL, NULL, icon, title); g_object_unref (icon); tooltip = g_strdup_printf (_("Rescan %s"), title); panel_util_set_tooltip_text (item, tooltip); g_free (tooltip); g_free (title); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect_data (item, "activate", G_CALLBACK (panel_menu_item_rescan_drive), g_object_ref (drive), (GClosureNotify) g_object_unref, 0); g_signal_connect (G_OBJECT (item), "button_press_event", G_CALLBACK (menu_dummy_button_press_event), NULL); }
/** * gimp_brush_select_widget_new: * @title: Title of the dialog to use or %NULL to use the default title. * @brush_name: Initial brush name or %NULL to use current selection. * @opacity: Initial opacity. -1 means to use current opacity. * @spacing: Initial spacing. -1 means to use current spacing. * @paint_mode: Initial paint mode. -1 means to use current paint mode. * @callback: A function to call when the selected brush changes. * @data: A pointer to arbitary data to be used in the call to @callback. * * Creates a new #GtkWidget that completely controls the selection of * a #GimpBrush. This widget is suitable for placement in a table in * a plug-in dialog. * * Returns: A #GtkWidget that you can use in your UI. */ GtkWidget * gimp_brush_select_widget_new (const gchar *title, const gchar *brush_name, gdouble opacity, gint spacing, GimpLayerModeEffects paint_mode, GimpRunBrushCallback callback, gpointer data) { GtkWidget *brush_button; CompatCallbackData *compat_data; g_return_val_if_fail (callback != NULL, NULL); brush_button = gimp_brush_select_button_new (title, brush_name, opacity, spacing, paint_mode); compat_data = g_slice_new (CompatCallbackData); compat_data->callback = callback; compat_data->data = data; g_signal_connect_data (brush_button, "brush-set", G_CALLBACK (compat_callback), compat_data, (GClosureNotify) compat_callback_data_free, 0); return brush_button; }
static GtkWidget * new_nsp_menu_item (NMDeviceWimax *device, NMConnection *connection, gboolean active, NMWimaxNsp *nsp, NMApplet *applet) { GtkWidget *item; WimaxMenuItemInfo *info; g_return_val_if_fail (nsp != NULL, NULL); item = nm_mb_menu_item_new (nm_wimax_nsp_get_name (nsp), nm_wimax_nsp_get_signal_quality (nsp), NULL, active, MB_TECH_WIMAX, nsp_type_to_mb_state (nm_wimax_nsp_get_network_type (nsp)), TRUE, applet); gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE); info = g_slice_new0 (WimaxMenuItemInfo); info->applet = applet; info->device = g_object_ref (G_OBJECT (device)); info->connection = connection ? g_object_ref (connection) : NULL; info->nsp = g_object_ref (nsp); g_signal_connect_data (item, "activate", G_CALLBACK (wimax_menu_item_activate), info, (GClosureNotify) wimax_menu_item_info_destroy, 0); return item; }
static void add_float_prop_base (ClutterActor *table, const char *name, FloatProp *prop, float value) { int table_y = mx_table_get_row_count (MX_TABLE (table)); ClutterActor *label; ClutterActor *slider; label = mx_label_new_with_text (name); mx_table_add_actor (MX_TABLE (table), label, table_y, 0); slider = mx_slider_new (); mx_table_add_actor (MX_TABLE (table), slider, table_y, 1); prop->label = mx_label_new (); mx_table_add_actor (MX_TABLE (table), prop->label, table_y, 2); mx_slider_set_value (MX_SLIDER (slider), (value - prop->min) / (prop->max - prop->min)); update_float_prop_label (prop, value); g_signal_connect_data (slider, "notify::value", G_CALLBACK (float_prop_value_cb), prop, (GClosureNotify) float_prop_free, 0); }
int main (int argc, char **argv) { BonoboObject *context; g_thread_init (NULL); if (!bonobo_init (&argc, argv)) g_error ("Could not initialize Bonobo"); orb = bonobo_orb (); create_bag (); print_props (); /* FIXME: this is unusual, with a factory you normally * want to use bonobo_running_context_auto_exit_unref */ context = bonobo_context_running_get (); g_signal_connect_data ( G_OBJECT (context), "last_unref", G_CALLBACK (quit_main), NULL, NULL, 0); bonobo_object_unref (context); bonobo_main (); return bonobo_debug_shutdown (); }
static void photos_base_item_print_load (GObject *source_object, GAsyncResult *res, gpointer user_data) { PhotosBaseItem *self = PHOTOS_BASE_ITEM (source_object); GtkWindow *toplevel = GTK_WINDOW (user_data); GeglNode *node; GtkPrintOperation *print_op; node = photos_base_item_load_finish (self, res, NULL); if (node == NULL) goto out; print_op = photos_print_operation_new (self, node); g_signal_connect_data (print_op, "done", G_CALLBACK (photos_base_item_print_operation_done), g_object_ref (self), (GClosureNotify) g_object_unref, G_CONNECT_SWAPPED); /* It is self managing. */ photos_print_notification_new (print_op); gtk_print_operation_run (print_op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, toplevel, NULL); out: g_clear_object (&node); g_object_unref (toplevel); }
GSource * _g_fd_source_new_with_object (GObject *object, int fd, gushort events, GCancellable *cancellable) { GSource *source; FDSource *fd_source; source = g_source_new (&fd_source_funcs, sizeof (FDSource)); fd_source = (FDSource *)source; if (cancellable) fd_source->cancellable = g_object_ref (cancellable); if (object) fd_source->object = g_object_ref (object); fd_source->pollfd.fd = fd; fd_source->pollfd.events = events; g_source_add_poll (source, &fd_source->pollfd); if (cancellable) fd_source->cancelled_tag = g_signal_connect_data (cancellable, "cancelled", (GCallback)fd_source_cancelled_cb, NULL, NULL, 0); return source; }
static void glide_binding_link_init (GlideBindingLink *link, GObject *src_object, const gchar *src_property, GObject *dst_object, GParamSpec *dst_pspec, GlideBindingTransform transform, GClosureNotify destroy_notify, gpointer user_data) { gchar *signal_name; link->dst_object = dst_object; link->dst_pspec = dst_pspec; link->dst_handler = 0; link->transform = transform; link->user_data = user_data; signal_name = g_strconcat ("notify::", src_property, NULL); link->handler = g_signal_connect_data ( src_object, signal_name, G_CALLBACK (e_bind_properties_notify), link, destroy_notify, 0); g_free (signal_name); }
static void panel_menu_items_append_place_item (const char *icon_name, GIcon *gicon, const char *title, const char *tooltip, GtkWidget *menu, GCallback callback, const char *uri) { GtkWidget *item; char *user_data; item = gtk_image_menu_item_new (); setup_menu_item_with_icon (item, panel_menu_icon_get_size (), icon_name, NULL, gicon, title); panel_util_set_tooltip_text (item, tooltip); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); user_data = g_strdup (uri); g_signal_connect_data (item, "activate", callback, user_data, (GClosureNotify) g_free, 0); g_signal_connect (G_OBJECT (item), "button_press_event", G_CALLBACK (menu_dummy_button_press_event), NULL); setup_uri_drag (item, uri, icon_name); }
/** * hildon_helper_set_logical_font: * @widget: a #GtkWidget to assign this logical font for. * @logicalfontname: a gchar* with the logical font name to assign to the widget. * * This function assigns a defined logical font to the @widget and all its child widgets. * it also connects to the "style_set" signal which will retrieve & assign the new font * for the given logical name each time the theme is changed * The returned signal id can be used to disconnect the signal. * When calling multiple times the previous signal (obtained by calling this function) is disconnected * automatically and should not be used. * * Return value: the signal id that is triggered every time theme is changed. 0 if font set failed. **/ gulong hildon_helper_set_logical_font (GtkWidget *widget, const gchar *logicalfontname) { gulong signum = 0; GSList *list; g_return_val_if_fail (GTK_IS_WIDGET (widget), 0); g_return_val_if_fail (logicalfontname != NULL, 0); list = attach_new_font_element (widget, logicalfontname); /* Disconnects the previously connected signals. That calls the closure notify * and effectively disposes the allocated data (hildon_logical_data_free) */ g_signal_handlers_disconnect_matched (G_OBJECT (widget), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, G_CALLBACK (hildon_change_style_recursive_from_list), NULL); /* Change the font now */ hildon_change_style_recursive_from_list (widget, NULL, list); /* Connect to "style_set" so that the font gets changed whenever theme changes. */ signum = g_signal_connect_data (G_OBJECT (widget), "style_set", G_CALLBACK (hildon_change_style_recursive_from_list), list, NULL, 0); return signum; }
/** * hildon_helper_set_logical_color: * @widget: A #GtkWidget to assign this logical font for. * @rcflags: #GtkRcFlags enumeration defining whether to assign to FG, BG, TEXT or BASE style. * @state: #GtkStateType indicating to which state to assign the logical color * @logicalcolorname: A gchar* with the logical font name to assign to the widget. * * This function assigns a defined logical color to the @widget and all it's child widgets. * It also connects to the "style_set" signal which will retrieve & assign the new color * for the given logical name each time the theme is changed. * The returned signal id can be used to disconnect the signal. * When calling multiple times the previous signal (obtained by calling this function) is disconnected * automatically and should not be used. * * Example : If the style you want to modify is bg[NORMAL] then set rcflags to GTK_RC_BG and state to GTK_STATE_NORMAL. * * Return value: The signal id that is triggered every time theme is changed. 0 if color set failed. **/ gulong hildon_helper_set_logical_color (GtkWidget *widget, GtkRcFlags rcflags, GtkStateType state, const gchar *logicalcolorname) { gulong signum = 0; GSList *list = NULL; g_return_val_if_fail (GTK_IS_WIDGET (widget), 0); g_return_val_if_fail (logicalcolorname != NULL, 0); list = attach_new_color_element (widget, rcflags, state, logicalcolorname); /* Disconnects the previously connected signals. */ g_signal_handlers_disconnect_matched (G_OBJECT (widget), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, G_CALLBACK (hildon_change_style_recursive_from_list), NULL); /* Change the colors now */ hildon_change_style_recursive_from_list (widget, NULL, list); /* Connect to "style_set" so that the colors gets changed whenever theme */ signum = g_signal_connect_data (G_OBJECT (widget), "style_set", G_CALLBACK (hildon_change_style_recursive_from_list), list, NULL, 0); return signum; }
/** * st_texture_cache_bind_pixbuf_property: * @cache: * @object: A #GObject with a property @property_name of type #GdkPixbuf * @property_name: Name of a property * * Create a #ClutterTexture which tracks the #GdkPixbuf value of a GObject property * named by @property_name. Unlike other methods in StTextureCache, the underlying * #CoglTexture is not shared by default with other invocations to this method. * * If the source object is destroyed, the texture will continue to show the last * value of the property. * * Return value: (transfer none): A new #ClutterActor */ ClutterActor * st_texture_cache_bind_pixbuf_property (StTextureCache *cache, GObject *object, const char *property_name) { ClutterTexture *texture; gchar *notify_key; StTextureCachePropertyBind *bind; texture = CLUTTER_TEXTURE (clutter_texture_new ()); bind = g_new0 (StTextureCachePropertyBind, 1); bind->cache = cache; bind->texture = texture; bind->source = object; g_object_weak_ref (G_OBJECT (texture), st_texture_cache_bind_weak_notify, bind); bind->weakref_active = TRUE; st_texture_cache_reset_texture (bind, property_name); notify_key = g_strdup_printf ("notify::%s", property_name); bind->notify_signal_id = g_signal_connect_data (object, notify_key, G_CALLBACK(st_texture_cache_on_pixbuf_notify), bind, (GClosureNotify)st_texture_cache_free_bind, 0); g_free (notify_key); return CLUTTER_ACTOR(texture); }
static void restore_selection (RBLibraryBrowser *widget, gint property_index, gboolean query_pending) { RBLibraryBrowserPrivate *priv = RB_LIBRARY_BROWSER_GET_PRIVATE (widget); RBPropertyView *view; GList *selections; SelectionRestoreData *data; view = g_hash_table_lookup (priv->property_views, (gpointer)browser_properties[property_index].type); selections = g_hash_table_lookup (priv->selections, (gpointer)browser_properties[property_index].type); if (query_pending) { g_object_ref (widget); data = g_new0 (SelectionRestoreData, 1); data->widget = widget; data->view = view; data->selections = selections; data->model = priv->input_model; data->handler_id = g_signal_connect_data (priv->input_model, "complete", G_CALLBACK (query_complete_cb), data, (GClosureNotify) selection_restore_data_destroy, 0); } else { ignore_selection_changes (widget, view, FALSE); rb_property_view_set_selection (view, selections); } }
void setup_internal_applet_drag (GtkWidget *menuitem, PanelActionButtonType type) { static GtkTargetEntry menu_item_targets[] = { { "application/x-mate-panel-applet-internal", 0, 0 } }; if (panel_lockdown_get_locked_down ()) return; gtk_drag_source_set (menuitem, GDK_BUTTON1_MASK|GDK_BUTTON2_MASK, menu_item_targets, 1, GDK_ACTION_COPY); if (panel_action_get_icon_name (type) != NULL) gtk_drag_source_set_icon_name (menuitem, panel_action_get_icon_name (type)); g_signal_connect (G_OBJECT (menuitem), "drag_begin", G_CALLBACK (drag_begin_menu_cb), NULL); g_signal_connect_data (G_OBJECT (menuitem), "drag_data_get", G_CALLBACK (drag_data_get_string_cb), g_strdup (panel_action_get_drag_id (type)), (GClosureNotify)g_free, 0 /* connect_flags */); g_signal_connect (G_OBJECT (menuitem), "drag_end", G_CALLBACK (drag_end_menu_cb), NULL); }
static gboolean gst_gsettings_audio_src_start (GstGSettingsAudioSrc * src) { GError *err = NULL; GThread *thread; src->loop = g_main_loop_new (src->context, FALSE); thread = g_thread_create ((GThreadFunc) g_main_loop_run, src->loop, FALSE, &err); if (!thread) { GST_ELEMENT_ERROR (src, CORE, STATE_CHANGE, (NULL), ("Failed to create new thread: %s", err->message)); g_error_free (err); g_main_loop_unref (src->loop); src->loop = NULL; return FALSE; } g_main_context_push_thread_default (src->context); src->settings = g_settings_new (GST_GSETTINGS_SCHEMA); src->changed_id = g_signal_connect_data (G_OBJECT (src->settings), "changed", G_CALLBACK (on_changed), gst_object_ref (src), (GClosureNotify) gst_object_unref, 0); g_main_context_pop_thread_default (src->context); return TRUE; }
void setup_uri_drag (GtkWidget *menuitem, const char *uri, const char *icon, GdkDragAction action) { static GtkTargetEntry menu_item_targets[] = { { "text/uri-list", 0, 0 } }; if (panel_lockdown_get_locked_down ()) return; gtk_drag_source_set (menuitem, GDK_BUTTON1_MASK|GDK_BUTTON2_MASK, menu_item_targets, 1, action); if (icon != NULL) gtk_drag_source_set_icon_name (menuitem, icon); g_signal_connect (G_OBJECT (menuitem), "drag_begin", G_CALLBACK (drag_begin_menu_cb), NULL); g_signal_connect_data (G_OBJECT (menuitem), "drag_data_get", G_CALLBACK (drag_data_get_string_cb), g_strdup (uri), (GClosureNotify)g_free, 0 /* connect_flags */); g_signal_connect (G_OBJECT (menuitem), "drag_end", G_CALLBACK (drag_end_menu_cb), NULL); }
/** * _gtk_text_util_append_special_char_menuitems * @menushell: a #GtkMenuShell * @callback: call this when an item is chosen * @data: data for callback * * Add menuitems for various bidi control characters to a menu; * the menuitems, when selected, will call the given function * with the chosen character. * * This function is private/internal in GTK 2.0, the functionality may * become public sometime, but it probably needs more thought first. * e.g. maybe there should be a way to just get the list of items, * instead of requiring the menu items to be created. **/ void _gtk_text_util_append_special_char_menuitems (GtkMenuShell *menushell, GtkTextUtilCharChosenFunc func, gpointer data) { int i; for (i = 0; i < G_N_ELEMENTS (bidi_menu_entries); i++) { GtkWidget *menuitem; GtkTextUtilCallbackInfo *info; /* wasteful to have a bunch of copies, but simplifies mem management */ info = g_new (GtkTextUtilCallbackInfo, 1); info->func = func; info->data = data; menuitem = gtk_menu_item_new_with_mnemonic (_(bidi_menu_entries[i].label)); g_object_set_data (G_OBJECT (menuitem), "gtk-unicode-menu-entry", &bidi_menu_entries[i]); g_signal_connect_data (menuitem, "activate", G_CALLBACK (activate_cb), info, (GClosureNotify) g_free, 0); gtk_widget_show (menuitem); gtk_menu_shell_append (menushell, menuitem); } }
/** * gimp_font_select_widget_new: * @title: Title of the dialog to use or %NULL to use the default title. * @font_name: Initial font name. * @callback: A function to call when the selected font changes. * @data: A pointer to arbitary data to be used in the call to @callback. * * Creates a new #GtkWidget that completely controls the selection of * a font. This widget is suitable for placement in a table in a * plug-in dialog. * * Returns: A #GtkWidget that you can use in your UI. */ GtkWidget * gimp_font_select_widget_new (const gchar *title, const gchar *font_name, GimpRunFontCallback callback, gpointer data) { GtkWidget *font_button; CompatCallbackData *compat_data; g_return_val_if_fail (callback != NULL, NULL); font_button = gimp_font_select_button_new (title, font_name); compat_data = g_slice_new (CompatCallbackData); compat_data->callback = callback; compat_data->data = data; g_signal_connect_data (font_button, "font-set", G_CALLBACK (compat_callback), compat_data, (GClosureNotify) compat_callback_data_free, 0); return font_button; }
static gboolean handle_create_thin_volume (LvmVolumeGroup *group, GDBusMethodInvocation *invocation, const gchar *arg_name, guint64 arg_size, const gchar *arg_pool, GVariant *options) { StorageVolumeGroup *self = STORAGE_VOLUME_GROUP (group); CompleteClosure *complete; StorageJob *job; StorageDaemon *daemon; StorageLogicalVolume *pool; gchar *size; daemon = storage_daemon_get (); pool = storage_daemon_find_thing (daemon, arg_pool, STORAGE_TYPE_LOGICAL_VOLUME); if (pool == NULL) { g_dbus_method_invocation_return_error (invocation, UDISKS_ERROR, UDISKS_ERROR_FAILED, "Not a valid logical volume"); return TRUE; } arg_size -= arg_size % 512; size = g_strdup_printf ("%" G_GUINT64_FORMAT "b", arg_size); job = storage_daemon_launch_spawned_job (daemon, self, "lvm-vg-create-volume", storage_invocation_get_caller_uid (invocation), NULL, /* GCancellable */ 0, /* uid_t run_as_uid */ 0, /* uid_t run_as_euid */ NULL, /* input_string */ "lvcreate", storage_volume_group_get_name (self), "--thinpool", storage_logical_volume_get_name (pool), "-V", size, "-n", arg_name, NULL); complete = g_new0 (CompleteClosure, 1); complete->invocation = g_object_ref (invocation); complete->wait_thing = g_object_ref (self); complete->wait_name = g_strdup (arg_name); /* Wait for the job to finish */ g_signal_connect (job, "completed", G_CALLBACK (on_create_complete), complete); /* Wait for the object to appear */ complete->wait_sig = g_signal_connect_data (daemon, "published::StorageLogicalVolume", G_CALLBACK (on_create_logical_volume), complete, complete_closure_free, 0); g_free (size); g_object_unref (pool); return TRUE; }
static inline gchar * get_node_key (DonnaColumnTypeName *ctname, struct tv_col_data *data, DonnaNode *node) { DonnaColumnTypeNamePrivate *priv = ctname->priv; gchar *key; gboolean dot_first = data->options & DONNA_SORT_DOT_FIRST; gboolean natural_order = data->options & DONNA_SORT_NATURAL_ORDER; key = g_object_get_data (G_OBJECT (node), data->collate_key); /* no key, or invalid (options changed) */ if (!key || *key != donna_sort_get_options_char (dot_first, data->sort_special_first, natural_order)) { gchar *name; /* if we're installing the key (i.e. not updating an invalid one) we * need to make sure we're listening on the provider's * node-updated::name signal, to remove the key on rename */ if (!key) { const gchar *domain; guint i; if (!priv->domains) priv->domains = g_ptr_array_new (); domain = donna_node_get_domain (node); for (i = 0; i < priv->domains->len; ++i) if (streq (domain, priv->domains->pdata[i])) break; /* no match, must connect */ if (i >= priv->domains->len) { /* FIXME? (not actually needed since our cb is "self-contained") * - also connect to a new signal "destroy" when provider is * being finalized. in handler, we remove it from the ptrarr * - when we're finalized, disconnect all hanlers */ g_signal_connect_data (donna_node_peek_provider (node), "node-updated::name", G_CALLBACK (node_updated_cb), g_strdup (data->collate_key), (GClosureNotify) g_free, 0); g_ptr_array_add (priv->domains, (gpointer) domain); } } name = donna_node_get_name (node); key = donna_sort_get_utf8_collate_key (name, -1, dot_first, data->sort_special_first, natural_order); g_free (name); g_object_set_data_full (G_OBJECT (node), data->collate_key, key, g_free); } return key + 1; /* skip options_char */ }
long CFGopen() { GtkBuilder *builder; GtkWidget *widget, *MainWindow; char buf[256]; LoadConf(); builder = gtk_builder_new(); if (!gtk_builder_add_from_resource(builder, "/org/pcsxr/dfnet/dfnet.ui", NULL)) { g_warning("We could not load the interface!"); return 0; } MainWindow = GTK_WIDGET(gtk_builder_get_object(builder, "dlgStart")); gtk_window_set_title(GTK_WINDOW(MainWindow), _("NetPlay")); widget = GTK_WIDGET(gtk_builder_get_object(builder, "btnCopyIP")); g_signal_connect_data(G_OBJECT(widget), "clicked", G_CALLBACK(OnCopyIP), NULL, NULL, G_CONNECT_AFTER); widget = GTK_WIDGET(gtk_builder_get_object(builder, "tbServerIP")); gtk_entry_set_text(GTK_ENTRY(widget), conf.ipAddress); widget = GTK_WIDGET(gtk_builder_get_object(builder, "tbPort")); sprintf(buf, "%d", conf.PortNum); gtk_entry_set_text(GTK_ENTRY(widget), buf); if (conf.PlayerNum == 1) { widget = GTK_WIDGET(gtk_builder_get_object(builder, "rbServer")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); } else { widget = GTK_WIDGET(gtk_builder_get_object(builder, "rbClient")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); } if (gtk_dialog_run(GTK_DIALOG(MainWindow)) == GTK_RESPONSE_OK) { widget = GTK_WIDGET(gtk_builder_get_object(builder, "tbServerIP")); strcpy(conf.ipAddress, gtk_entry_get_text(GTK_ENTRY(widget))); widget = GTK_WIDGET(gtk_builder_get_object(builder, "tbPort")); conf.PortNum = atoi(gtk_entry_get_text(GTK_ENTRY(widget))); widget = GTK_WIDGET(gtk_builder_get_object(builder, "rbServer")); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { conf.PlayerNum = 1; } else { conf.PlayerNum = 2; } SaveConf(); gtk_widget_destroy(MainWindow); return 1; } gtk_widget_destroy(MainWindow); return 0; }