本文整理汇总了C++中G_CALLBACK函数 的典型用法代码示例。如果您正苦于以下问题:C++ G_CALLBACK函数的具体用法?C++ G_CALLBACK怎么用?C++ G_CALLBACK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_CALLBACK函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc,
char *argv[] )
{
GtkWidget *window;
GtkWidget *drawing_area;
GtkWidget *vbox;
GtkWidget *v1box;
GtkWidget *hbox;
GtkWidget *button;
gtk_init (&argc, &argv);
printf("Helo\n");
int i,j;
for(i=0;i<1000;i++)
{
for(j=0;j<1000;j++)
{
pixels[i][j]=0;
visited[i][j]=0;
}
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(window), "pencil_project");
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show (vbox);
g_signal_connect (GTK_WINDOW(window), "destroy",
G_CALLBACK (quit), NULL);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
v1box = newVerticalbox ( FALSE, 0, TRUE, TRUE, 0 );
gtk_box_pack_start (GTK_BOX (hbox), v1box, FALSE, FALSE, 0);
gtk_widget_show (v1box);
/* Create the drawing area */
drawing_area = gtk_drawing_area_new ();
gtk_widget_set_size_request (GTK_WIDGET (drawing_area), breadth, height);//breadth,height global variables in buttons.h
//cr = gdk_cairo_create(drawing_area->window);
gtk_box_pack_start (GTK_BOX (hbox), drawing_area, TRUE, TRUE, 0);
gtk_widget_show (drawing_area);
g_signal_connect (drawing_area, "expose_event",
G_CALLBACK (expose_event),NULL);
/* g_signal_connect (drawing_area, "configure_event",
G_CALLBACK (configure_event), NULL);
/* Event signals */
g_signal_connect (drawing_area, "motion_notify_event",
G_CALLBACK (motion_notify_event), NULL);//made them null as it don't have significance.
handler_id = g_signal_connect (drawing_area, "button_press_event",
G_CALLBACK (button_press_event), NULL);
gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK
|GDK_LEAVE_NOTIFY_MASK
| GDK_BUTTON_PRESS_MASK
|GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK);
button = horizontal_box ( FALSE, 0, TRUE, TRUE, 0, TRUE );
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = horizontal_box ( FALSE, 0, TRUE, TRUE, 0, FALSE );
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Fill");
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
g_signal_connect_swapped (button, "clicked", G_CALLBACK (button_press_event_fill), drawing_area);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
开发者ID:mdilip, 项目名称:Programming-lab-assignment, 代码行数:83, 代码来源:pro_circle.c
示例2: la_handler_service_handle_register
static gboolean
la_handler_service_handle_register (LAHandler *interface,
GDBusMethodInvocation *invocation,
const gchar *unit,
NSMShutdownType shutdown_mode,
guint timeout,
LAHandlerService *service)
{
ShutdownConsumer *consumer;
ShutdownClient *client;
GError *error = NULL;
const gchar *existing_bus_name;
const gchar *existing_object_path;
gchar *bus_name;
gchar *object_path;
g_return_val_if_fail (IS_LA_HANDLER (interface), FALSE);
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
g_return_val_if_fail (unit != NULL && *unit != '\0', FALSE);
g_return_val_if_fail (LA_HANDLER_IS_SERVICE (service), FALSE);
if (shutdown_mode != NSM_SHUTDOWN_TYPE_NORMAL
&& shutdown_mode != NSM_SHUTDOWN_TYPE_FAST
&& shutdown_mode != (NSM_SHUTDOWN_TYPE_NORMAL | NSM_SHUTDOWN_TYPE_FAST))
{
/* the shutdown mode is invalid */
DLT_LOG (la_handler_context, DLT_LOG_ERROR,
DLT_STRING ("Failed to register legacy application: "
"invalid shutdown mode"), DLT_INT (shutdown_mode));
la_handler_complete_register (interface, invocation);
return TRUE;
}
/* find out if we have a shutdown client for this unit already */
client = g_hash_table_lookup (service->units_to_clients, unit);
if (client != NULL)
{
/* there already is a shutdown client for the unit, so simply
* re-register its client with the new shutdown mode and timeout */
/* extract information from the client */
existing_bus_name = shutdown_client_get_bus_name (client);
existing_object_path = shutdown_client_get_object_path (client);
/* temporarily store a reference to the legacy app handler service object
* in the invocation object */
g_object_set_data_full (G_OBJECT (invocation), "la-handler-service",
g_object_ref (service), (GDestroyNotify) g_object_unref);
/* re-register the shutdown consumer with the NSM Consumer */
nsm_consumer_call_register_shutdown_client (service->nsm_consumer,
existing_bus_name, existing_object_path,
shutdown_mode, timeout, NULL,
la_handler_service_handle_register_finish,
invocation);
}
else
{
/* create a new shutdown client and consumer for the unit */
bus_name = "org.genivi.NodeStartupController1";
object_path = g_strdup_printf ("%s/%u", service->prefix, service->index);
client = shutdown_client_new (bus_name, object_path, shutdown_mode, timeout);
consumer = shutdown_consumer_skeleton_new ();
shutdown_client_set_consumer (client, consumer);
/* remember the legacy app handler service object in shutdown client */
g_object_set_data_full (G_OBJECT (client), "la-handler-service",
g_object_ref (service), (GDestroyNotify) g_object_unref);
/* implement the LifecycleRequest method of the shutdown consumer */
g_signal_connect (consumer, "handle-lifecycle-request",
G_CALLBACK (la_handler_service_handle_consumer_lifecycle_request),
client);
/* associate the shutdown client with the unit name */
g_hash_table_insert (service->units_to_clients, g_strdup (unit),
g_object_ref (client));
g_hash_table_insert (service->clients_to_units, g_object_ref (client),
g_strdup (unit));
/* export the shutdown consumer on the bus */
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (consumer),
service->connection, object_path, &error);
if (error != NULL)
{
DLT_LOG (la_handler_context, DLT_LOG_ERROR,
DLT_STRING ("Failed to export shutdown consumer on the bus:"),
DLT_STRING (error->message));
g_error_free (error);
}
/* temporarily store a reference to the legacy app handler service object
* in the invocation object */
g_object_set_data_full (G_OBJECT (invocation), "la-handler-service",
g_object_ref (service), (GDestroyNotify) g_object_unref);
/* register the shutdown consumer with the NSM Consumer */
nsm_consumer_call_register_shutdown_client (service->nsm_consumer,
bus_name, object_path,
shutdown_mode, timeout, NULL,
//.........这里部分代码省略.........
开发者ID:wozhu6104, 项目名称:node-startup-controller, 代码行数:101, 代码来源:la-handler-service.c
示例3: main
int
main (int argc, char *argv[])
{
GOptionContext *context;
GSocketClient *client;
GSocketConnection *connection;
GSocketAddress *address;
GCancellable *cancellable;
GOutputStream *out;
GError *error = NULL;
char buffer[1000];
context = g_option_context_new (" <hostname>[:port] - send data to tcp host");
g_option_context_add_main_entries (context, cmd_entries, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error))
{
g_printerr ("%s: %s\n", argv[0], error->message);
return 1;
}
if (argc != 2)
{
g_printerr ("%s: %s\n", argv[0], "Need to specify hostname");
return 1;
}
if (async)
loop = g_main_loop_new (NULL, FALSE);
if (cancel_timeout)
{
GThread *thread;
cancellable = g_cancellable_new ();
thread = g_thread_new ("cancel", cancel_thread, cancellable);
g_thread_unref (thread);
}
else
{
cancellable = NULL;
}
client = g_socket_client_new ();
if (io_timeout)
g_socket_client_set_timeout (client, io_timeout);
if (verbose)
g_signal_connect (client, "event", G_CALLBACK (socket_client_event), NULL);
if (async)
{
GAsyncResult *res;
g_socket_client_connect_to_host_async (client, argv[1], 7777,
cancellable, async_cb, &res);
g_main_loop_run (loop);
connection = g_socket_client_connect_to_host_finish (client, res, &error);
g_object_unref (res);
}
else
{
connection = g_socket_client_connect_to_host (client,
argv[1],
7777,
cancellable, &error);
}
if (connection == NULL)
{
g_printerr ("%s can't connect: %s\n", argv[0], error->message);
return 1;
}
g_object_unref (client);
address = g_socket_connection_get_remote_address (connection, &error);
if (!address)
{
g_printerr ("Error getting remote address: %s\n",
error->message);
return 1;
}
g_print ("Connected to address: %s\n",
socket_address_to_string (address));
g_object_unref (address);
if (graceful)
g_tcp_connection_set_graceful_disconnect (G_TCP_CONNECTION (connection), TRUE);
out = g_io_stream_get_output_stream (G_IO_STREAM (connection));
while (fgets(buffer, sizeof (buffer), stdin) != NULL)
{
/* FIXME if (async) */
if (!g_output_stream_write_all (out, buffer, strlen (buffer),
NULL, cancellable, &error))
{
g_warning ("send error: %s\n", error->message);
g_error_free (error);
error = NULL;
}
}
g_print ("closing stream\n");
if (async)
//.........这里部分代码省略.........
开发者ID:183amir, 项目名称:glib, 代码行数:101, 代码来源:send-data.c
示例4: xfapplet_applet_activated
static void
xfapplet_applet_activated (MateComponent_Unknown object, CORBA_Environment *ev, gpointer data)
{
GtkWidget *bw, *child = NULL;
CORBA_Object control;
CORBA_Environment corba_ev;
MateComponentControlFrame *frame;
MateComponentUIComponent *uic;
MateComponent_PropertyBag prop_bag;
XfAppletPlugin *xap = (XfAppletPlugin*) data;
gchar *error;
if (MATECOMPONENT_EX (ev) || object == CORBA_OBJECT_NIL) {
error = matecomponent_exception_get_text (ev);
CORBA_exception_free (ev);
g_warning ("Failed to load applet '%s' (can't get CORBA object): %s\n", xap->iid, error);
xfapplet_applet_load_failed (xap);
xfapplet_cleanup_current (xap);
g_free (error);
return;
}
control = CORBA_Object_duplicate (object, NULL);
bw = matecomponent_widget_new_control_from_objref (object, CORBA_OBJECT_NIL);
matecomponent_object_release_unref (object, NULL);
if (!bw) {
g_warning ("Failed to load applet '%s' (can't get matecomponent widget)\n", xap->iid);
xfapplet_applet_load_failed (xap);
xfapplet_cleanup_current (xap);
return;
}
frame = matecomponent_widget_get_control_frame (MATECOMPONENT_WIDGET (bw));
if (!frame) {
g_warning ("Failed to load applet '%s' (can't get control frame)\n", xap->iid);
gtk_object_sink (GTK_OBJECT (bw));
xfapplet_applet_load_failed (xap);
xfapplet_cleanup_current (xap);
return;
}
CORBA_exception_init (&corba_ev);
prop_bag = matecomponent_control_frame_get_control_property_bag (frame, &corba_ev);
if (prop_bag == NULL || MATECOMPONENT_EX (&corba_ev)) {
error = matecomponent_exception_get_text (&corba_ev);
CORBA_exception_free (&corba_ev);
g_warning ("Failed to load applet '%s' (can't get property bag): %s\n", xap->iid, error);
gtk_object_sink (GTK_OBJECT (bw));
xfapplet_applet_load_failed (xap);
xfapplet_cleanup_current (xap);
g_free (error);
return;
}
uic = matecomponent_control_frame_get_popup_component (frame, &corba_ev);
if (uic == NULL || MATECOMPONENT_EX (&corba_ev)) {
error = matecomponent_exception_get_text (&corba_ev);
CORBA_exception_free (&corba_ev);
g_warning ("Failed to load applet '%s' (can't get popup component): %s\n", xap->iid, error);
gtk_object_sink (GTK_OBJECT (bw));
xfapplet_applet_load_failed (xap);
xfapplet_cleanup_current (xap);
g_free (error);
return;
}
matecomponent_ui_component_freeze (uic, CORBA_OBJECT_NIL);
xfce_textdomain ("xfce4-panel", LIBXFCE4PANEL_LOCALE_DIR, "UTF-8");
matecomponent_ui_util_set_ui (uic, PKGDATADIR "/ui", "XFCE_Panel_Popup.xml", "xfce4-xfapplet-plugin", &corba_ev);
if (MATECOMPONENT_EX (&corba_ev)) {
error = matecomponent_exception_get_text (&corba_ev);
CORBA_exception_free (&corba_ev);
g_warning ("Failed to load applet '%s' (can't set ui): %s\n", xap->iid, error);
gtk_object_sink (GTK_OBJECT (bw));
xfapplet_applet_load_failed (xap);
xfapplet_cleanup_current (xap);
g_free (error);
return;
}
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
xfapplet_setup_menu_items (xap->plugin, uic);
matecomponent_ui_component_thaw (uic, CORBA_OBJECT_NIL);
gtk_widget_show (bw);
if (xap->configured)
xfapplet_unload_applet (xap);
xap->object = control;
xap->uic = uic;
xap->prop_bag = prop_bag;
MateCORBA_small_listen_for_broken (object, G_CALLBACK (xfapplet_connection_broken), xap);
child = xfapplet_get_plugin_child (xap->plugin);
if (child)
gtk_widget_destroy (child);
gtk_container_add (GTK_CONTAINER(xap->plugin), bw);
xap->configured = TRUE;
//.........这里部分代码省略.........
开发者ID:fatman2021, 项目名称:xfce4-xfapplet-plugin, 代码行数:101, 代码来源:xfapplet.c
示例5: cinnamon_control_center_init
static void
cinnamon_control_center_init (CinnamonControlCenter *self)
{
GError *err = NULL;
CinnamonControlCenterPrivate *priv;
GdkScreen *screen;
GtkWidget *widget;
priv = self->priv = CONTROL_CENTER_PRIVATE (self);
priv->monitor_num = -1;
self->priv->small_screen = SMALL_SCREEN_UNSET;
/* load the user interface */
priv->builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (priv->builder, UIDIR "/shell.ui", &err))
{
g_critical ("Could not build interface: %s", err->message);
g_error_free (err);
return;
}
/* connect various signals */
priv->window = W (priv->builder, "main-window");
gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (priv->window), TRUE);
screen = gtk_widget_get_screen (priv->window);
g_signal_connect (screen, "monitors-changed", G_CALLBACK (monitors_changed_cb), self);
g_signal_connect (priv->window, "configure-event", G_CALLBACK (main_window_configure_cb), self);
g_signal_connect (priv->window, "notify::application", G_CALLBACK (application_set_cb), self);
g_signal_connect_swapped (priv->window, "delete-event", G_CALLBACK (g_object_unref), self);
g_signal_connect_after (priv->window, "key_press_event",
G_CALLBACK (window_key_press_event), self);
priv->notebook = W (priv->builder, "notebook");
/* Main scrolled window */
priv->scrolled_window = W (priv->builder, "scrolledwindow1");
if (!g_strcmp0(g_getenv("XDG_CURRENT_DESKTOP"), "Unity"))
gtk_widget_set_size_request (priv->scrolled_window, UNITY_FIXED_WIDTH, -1);
else
gtk_widget_set_size_request (priv->scrolled_window, FIXED_WIDTH, -1);
priv->main_vbox = W (priv->builder, "main-vbox");
g_signal_connect (priv->notebook, "notify::page",
G_CALLBACK (notebook_page_notify_cb), priv);
priv->nav_bar = cc_shell_nav_bar_new ();
widget = W (priv->builder, "hbox1");
gtk_box_pack_start (GTK_BOX (widget), priv->nav_bar, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (widget), priv->nav_bar, 0);
gtk_widget_show (priv->nav_bar);
g_signal_connect (priv->nav_bar,
"home-clicked", G_CALLBACK (home_button_clicked_cb), self);
/* keep a list of custom widgets to unload on panel change */
priv->custom_widgets = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
/* load the available settings panels */
setup_model (self);
/* load the panels that are implemented as plugins */
load_panel_plugins (self);
/* setup search functionality */
setup_search (self);
setup_lock (self);
/* store default window title and name */
priv->default_window_title = g_strdup (gtk_window_get_title (GTK_WINDOW (priv->window)));
priv->default_window_icon = g_strdup (gtk_window_get_icon_name (GTK_WINDOW (priv->window)));
notebook_page_notify_cb (GTK_NOTEBOOK (priv->notebook), NULL, priv);
}
开发者ID:3dfxmadscientist, 项目名称:cinnamon-control-center, 代码行数:77, 代码来源:cinnamon-control-center.c
示例6: main
int
main (int argc, char *argv[])
{
ClutterActor *stage, *actor;
ClutterColor rcol = { 0xff, 0, 0, 0xff},
bcol = { 0, 0, 0xff, 0xff },
gcol = { 0, 0xff, 0, 0xff },
ccol = { 0, 0xff, 0xff, 0xff },
ycol = { 0xff, 0xff, 0, 0xff };
clutter_init (&argc, &argv);
g_print ("Red box: aquire grab on press, releases it on next button release\n");
g_print ("Blue box: aquire grab on press, destroys the blue box actor on release\n");
g_print ("Yellow box: aquire grab on press, releases grab on next press on yellow box\n");
g_print ("Green box: toggle per actor motion events.\n\n");
g_print ("Cyan box: toggle grab (from cyan box) for keyboard events.\n\n");
stage = clutter_stage_get_default ();
g_signal_connect (stage, "event", G_CALLBACK (debug_event_cb), "stage");
g_signal_connect (stage, "fullscreen",
G_CALLBACK (stage_state_cb), "fullscreen");
g_signal_connect (stage, "unfullscreen",
G_CALLBACK (stage_state_cb), "unfullscreen");
g_signal_connect (stage, "activate",
G_CALLBACK (stage_state_cb), "activate");
g_signal_connect (stage, "deactivate",
G_CALLBACK (stage_state_cb), "deactivate");
actor = clutter_rectangle_new_with_color (&rcol);
clutter_actor_set_size (actor, 100, 100);
clutter_actor_set_position (actor, 100, 100);
clutter_actor_set_reactive (actor, TRUE);
clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
g_signal_connect (actor, "event", G_CALLBACK (debug_event_cb), "red box");
g_signal_connect (actor, "button-press-event",
G_CALLBACK (grab_pointer_cb), NULL);
g_signal_connect (actor, "button-release-event",
G_CALLBACK (red_release_cb), NULL);
actor = clutter_rectangle_new_with_color (&ycol);
clutter_actor_set_size (actor, 100, 100);
clutter_actor_set_position (actor, 100, 300);
clutter_actor_set_reactive (actor, TRUE);
clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
g_signal_connect (actor, "event", G_CALLBACK (debug_event_cb), "yellow box");
g_signal_connect (actor, "button-press-event",
G_CALLBACK (toggle_grab_pointer_cb), NULL);
actor = clutter_rectangle_new_with_color (&bcol);
clutter_actor_set_size (actor, 100, 100);
clutter_actor_set_position (actor, 300, 100);
clutter_actor_set_reactive (actor, TRUE);
clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
g_signal_connect (actor, "event",
G_CALLBACK (debug_event_cb), "blue box");
g_signal_connect (actor, "button-press-event",
G_CALLBACK (grab_pointer_cb), NULL);
g_signal_connect (actor, "button-release-event",
G_CALLBACK (blue_release_cb), NULL);
actor = clutter_rectangle_new_with_color (&gcol);
clutter_actor_set_size (actor, 100, 100);
clutter_actor_set_position (actor, 300, 300);
clutter_actor_set_reactive (actor, TRUE);
clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
g_signal_connect (actor, "event",
G_CALLBACK (debug_event_cb), "green box");
g_signal_connect (actor, "button-press-event",
G_CALLBACK (green_press_cb), NULL);
actor = clutter_rectangle_new_with_color (&ccol);
clutter_actor_set_size (actor, 100, 100);
clutter_actor_set_position (actor, 500, 100);
clutter_actor_set_reactive (actor, TRUE);
clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
g_signal_connect (actor, "event",
G_CALLBACK (debug_event_cb), "cyan box");
g_signal_connect (actor, "button-press-event",
G_CALLBACK (cyan_press_cb), NULL);
clutter_actor_show_all (CLUTTER_ACTOR (stage));
clutter_main();
return 0;
}
开发者ID:archlinuxarm-n900, 项目名称:clutter08, 代码行数:89, 代码来源:test-grab.c
示例7: main
int
main (int argc, char **argv)
{
gint ret;
GMainLoop *loop;
PolkitAgentListener *listener;
GError *error;
gtk_init (&argc, &argv);
loop = NULL;
authority = NULL;
listener = NULL;
session = NULL;
ret = 1;
bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
#if HAVE_BIND_TEXTDOMAIN_CODESET
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
textdomain (GETTEXT_PACKAGE);
loop = g_main_loop_new (NULL, FALSE);
error = NULL;
authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
if (authority == NULL)
{
g_warning ("Error getting authority: %s", error->message);
g_error_free (error);
goto out;
}
g_signal_connect (authority,
"changed",
G_CALLBACK (on_authority_changed),
NULL);
listener = polkit_mate_listener_new ();
error = NULL;
session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
if (error != NULL)
{
g_warning ("Unable to determine the session we are in: %s", error->message);
g_error_free (error);
goto out;
}
error = NULL;
if (!polkit_agent_listener_register (listener,
POLKIT_AGENT_REGISTER_FLAGS_NONE,
session,
"/org/mate/PolicyKit1/AuthenticationAgent",
NULL,
&error))
{
g_printerr ("Cannot register authentication agent: %s\n", error->message);
g_error_free (error);
goto out;
}
update_temporary_authorization_icon (authority);
g_main_loop_run (loop);
ret = 0;
out:
if (authority != NULL)
g_object_unref (authority);
if (session != NULL)
g_object_unref (session);
if (listener != NULL)
g_object_unref (listener);
if (loop != NULL)
g_main_loop_unref (loop);
return ret;
}
开发者ID:fatman2021, 项目名称:mate-polkit, 代码行数:79, 代码来源:main.c
示例8: update_temporary_authorization_icon_real
static void
update_temporary_authorization_icon_real (void)
{
#if 0
GList *l;
g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
for (l = current_temporary_authorizations; l != NULL; l = l->next)
{
PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
polkit_temporary_authorization_get_action_id (authz),
polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
polkit_temporary_authorization_get_id (authz),
(gint) polkit_temporary_authorization_get_time_obtained (authz),
(gint) polkit_temporary_authorization_get_time_expires (authz));
}
#endif
/* TODO:
*
* - we could do something fancy like displaying a window with the tmp authz
* when the icon is clicked...
*
* - we could do some work using polkit_subject_exists() to ignore tmp authz
* for subjects that no longer exists.. this is because temporary authorizations
* are only valid for the subject that trigger the authentication dialog.
*
* Maybe the authority could do this, would probably involve some polling, but
* it seems cleaner to do this server side.
*/
if (current_temporary_authorizations != NULL)
{
/* show icon */
if (status_icon == NULL)
{
status_icon = gtk_status_icon_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION);
gtk_status_icon_set_tooltip_text (status_icon,
_("Click the icon to drop all elevated privileges"));
g_signal_connect (status_icon,
"activate",
G_CALLBACK (on_status_icon_activate),
NULL);
g_signal_connect (status_icon,
"popup-menu",
G_CALLBACK (on_status_icon_popup_menu),
NULL);
}
}
else
{
/* hide icon */
if (status_icon != NULL)
{
gtk_status_icon_set_visible (status_icon, FALSE);
g_object_unref (status_icon);
status_icon = NULL;
}
}
}
开发者ID:fatman2021, 项目名称:mate-polkit, 代码行数:62, 代码来源:main.c
示例9: cg_combo_flags_popup_idle
static gboolean
cg_combo_flags_popup_idle (gpointer data)
{
CgComboFlags *combo;
CgComboFlagsPrivate *priv;
GtkTreeSelection* selection;
GtkWidget *toplevel;
GtkWidget *scrolled;
GdkWindow *window;
GdkDeviceManager* device_manager;
gint height, width, x, y;
combo = CG_COMBO_FLAGS (data);
priv = CG_COMBO_FLAGS_PRIVATE (combo);
g_assert (priv->window == NULL);
priv->window = gtk_window_new (GTK_WINDOW_POPUP);
g_object_ref (G_OBJECT (priv->window));
gtk_window_set_resizable (GTK_WINDOW (priv->window), FALSE);
g_signal_connect (G_OBJECT (priv->window), "key_press_event",
G_CALLBACK (cg_combo_flags_window_key_press_cb),
combo);
g_signal_connect (G_OBJECT (priv->window), "button_press_event",
G_CALLBACK (cg_combo_flags_window_button_press_cb),
combo);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (priv->window), scrolled);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
gtk_widget_show (scrolled);
priv->treeview = gtk_tree_view_new_with_model (priv->model);
gtk_widget_show (priv->treeview);
gtk_container_add (GTK_CONTAINER (scrolled), priv->treeview);
g_signal_connect (G_OBJECT (priv->treeview), "key_press_event",
G_CALLBACK (cg_combo_flags_treeview_key_press_cb),
combo);
g_signal_connect (G_OBJECT (priv->treeview), "button_press_event",
G_CALLBACK (cg_combo_flags_treeview_button_press_cb),
combo);
priv->column = gtk_tree_view_column_new ();
g_object_ref (G_OBJECT (priv->column));
cg_combo_flags_sync_cells (combo, GTK_CELL_LAYOUT (priv->column));
gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), priv->column);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (priv->treeview), FALSE);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE);
gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (priv->treeview), TRUE);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo));
if (GTK_IS_WINDOW (toplevel))
{
gtk_window_group_add_window (gtk_window_get_group (
GTK_WINDOW (toplevel)),
GTK_WINDOW (priv->window));
gtk_window_set_transient_for (GTK_WINDOW (priv->window),
GTK_WINDOW (toplevel));
}
gtk_window_set_screen (GTK_WINDOW (priv->window),
gtk_widget_get_screen (GTK_WIDGET (combo)));
cg_combo_flags_get_position (combo, &x, &y, &width, &height);
gtk_widget_set_size_request (priv->window, width, height);
gtk_window_move (GTK_WINDOW(priv->window), x, y);
gtk_widget_show (priv->window);
gtk_widget_grab_focus (priv->window);
if (!gtk_widget_has_focus (priv->treeview))
gtk_widget_grab_focus (priv->treeview);
window = gtk_widget_get_window (priv->window);
device_manager = gdk_display_get_device_manager (gdk_window_get_display (window));
priv->pointer_device = gdk_device_manager_get_client_pointer (device_manager);
priv->keyboard_device = gdk_device_get_associated_device (priv->pointer_device);
gtk_grab_add (priv->window);
gdk_device_grab (priv->pointer_device, window, GDK_OWNERSHIP_NONE, TRUE,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
NULL, GDK_CURRENT_TIME);
//.........这里部分代码省略.........
开发者ID:GNOME, 项目名称:anjuta, 代码行数:101, 代码来源:combo-flags.c
示例10: main
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
if ( ! parse_commandline(argc, argv) )
return(EXIT_FAILURE);
sterm::common::set_debugging(opt_debug);
if ( opt_config_file != NULL )
config_file = opt_config_file;
configuration = new sterm::config(config_file);
gtk_window_set_default_icon_name("utilities-terminal");
main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(main_window), "STerm");
gtk_container_set_border_width(GTK_CONTAINER(main_window), 0);
terminal = new sterm::terminal(configuration);
std::string child_command;
if ( opt_command != NULL )
child_command = opt_command;
terminal->attach_to_container(GTK_CONTAINER(main_window));
terminal->spawn_child(child_command);
terminal->connect_callback("child-exited", G_CALLBACK(main_exit_with_status_cb), NULL);
terminal->connect_callback("bell", G_CALLBACK(main_bell_cb), NULL);
terminal->link_property_to_terminal("window-title", G_OBJECT(main_window), "title");
g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(main_exit_cb), &main_window);
functions = new sterm::function_handler(configuration, terminal);
gtk_widget_show_all(main_window);
gtk_main();
if ( terminal != NULL ) {
delete(terminal);
terminal = NULL;
}
if ( functions != NULL ) {
delete(functions);
functions = NULL;
}
if ( configuration != NULL ) {
delete(configuration);
configuration = NULL;
}
if ( main_window != NULL ) {
gtk_widget_destroy(main_window);
main_window = NULL;
}
return ret;
}
开发者ID:flocke, 项目名称:sterm, 代码行数:63, 代码来源:main.cpp
示例11: calendar_sources_load_esource_list
static void
calendar_sources_load_esource_list (CalendarSourceData *source_data)
{
GSList *clients = NULL;
GSList *groups, *l;
gboolean emit_signal = FALSE;
g_return_if_fail (source_data->esource_list != NULL);
debug_dump_selected_sources (source_data->selected_sources);
dprintf ("Source groups:\n");
groups = e_source_list_peek_groups (source_data->esource_list);
for (l = groups; l; l = l->next)
{
GSList *esources, *s;
dprintf (" %s\n", e_source_group_peek_uid (l->data));
dprintf (" sources:\n");
esources = e_source_group_peek_sources (l->data);
for (s = esources; s; s = s->next)
{
ESource *esource = E_SOURCE (s->data);
ECal *client;
dprintf (" type = '%s' uid = '%s', name = '%s', relative uri = '%s': \n",
source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task",
e_source_peek_uid (esource),
e_source_peek_name (esource),
e_source_peek_relative_uri (esource));
if (is_source_selected (esource, source_data->selected_sources) &&
(client = get_ecal_from_source (esource, source_data->source_type, source_data->clients)))
{
clients = g_slist_prepend (clients, client);
}
}
}
dprintf ("\n");
if (source_data->loaded &&
!compare_ecal_lists (source_data->clients, clients))
emit_signal = TRUE;
for (l = source_data->clients; l; l = l->next)
{
g_signal_handlers_disconnect_by_func (G_OBJECT (l->data),
G_CALLBACK (backend_died_cb),
source_data);
g_object_unref (l->data);
}
g_slist_free (source_data->clients);
source_data->clients = g_slist_reverse (clients);
/* connect to backend_died after we disconnected the previous signal
* handlers. If we do it before, we'll lose some handlers (for clients that
* were already there before) */
for (l = source_data->clients; l; l = l->next)
{
g_signal_connect (G_OBJECT (l->data), "backend_died",
G_CALLBACK (backend_died_cb), source_data);
}
if (emit_signal)
{
dprintf ("Emitting %s-sources-changed signal\n",
source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task");
g_signal_emit (source_data->sources, source_data->changed_signal, 0);
}
debug_dump_ecal_list (source_data->clients);
}
开发者ID:TheCoffeMaker, 项目名称:Mate-Desktop-Environment, 代码行数:74, 代码来源:calendar-sources.c
示例12: dt_styles_create_from_style
void
dt_styles_create_from_style (const char *name, const char *newname, const char *description, GList *filter)
{
sqlite3_stmt *stmt;
int id=0;
int oldid=0;
oldid = dt_styles_get_id_by_name(name);
if(oldid == 0) return;
/* create the style header */
if (!dt_styles_create_style_header(newname, description)) return;
if ((id=dt_styles_get_id_by_name(newname)) != 0)
{
if (filter)
{
GList *list=filter;
char tmp[64];
char include[2048]= {0};
g_strlcat(include,"num in (", 2048);
do
{
if(list!=g_list_first(list))
g_strlcat(include,",", 2048);
sprintf(tmp,"%ld",(long int)list->data);
g_strlcat(include,tmp, 2048);
}
while ((list=g_list_next(list)));
g_strlcat(include,")", 2048);
char query[4096]= {0};
sprintf(query,"insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params,blendop_version) select ?1, num,module,operation,op_params,enabled,blendop_params,blendop_version from style_items where styleid=?2 and %s",include);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), query, -1, &stmt, NULL);
}
else
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params,blendop_version) select ?1, num,module,operation,op_params,enabled,blendop_params,blendop_version from style_items where style_id=?2", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, oldid);
sqlite3_step (stmt);
sqlite3_finalize (stmt);
/* backup style to disk */
char stylesdir[1024];
dt_loc_get_user_config_dir(stylesdir, 1024);
g_strlcat(stylesdir,"/styles",1024);
g_mkdir_with_parents(stylesdir,00755);
dt_styles_save_to_file(newname,stylesdir,FALSE);
char tmp_accel[1024];
gchar* tmp_name = g_strdup(newname); // freed by _destro_style_shortcut_callback
snprintf(tmp_accel,1024,"styles/Apply %s",newname);
dt_accel_register_global( tmp_accel, 0, 0);
GClosure *closure;
closure = g_cclosure_new(
G_CALLBACK(_apply_style_shortcut_callback),
tmp_name, _destroy_style_shortcut_callback);
dt_accel_connect_global(tmp_accel, closure);
dt_control_log(_("style named '%s' successfully created"),newname);
}
}
开发者ID:ksyz, 项目名称:darktable, 代码行数:62, 代码来源:styles.c
示例13: dt_styles_update
void
dt_styles_update (const char *name, const char *newname, const char *newdescription, GList *filter)
{
sqlite3_stmt *stmt;
int id=0;
gchar *desc = NULL;
id = dt_styles_get_id_by_name(name);
if(id == 0) return;
desc = dt_styles_get_description (name);
if ((g_strcmp0(name, newname)) || (g_strcmp0(desc, newdescription)))
{
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "update styles set name=?1, description=?2 where rowid=?3", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 1, newname, strlen (newname), SQLITE_STATIC);
DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 2, newdescription, strlen (newdescription), SQLITE_STATIC);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
if (filter)
{
GList *list=filter;
char tmp[64];
char include[2048] = {0};
g_strlcat(include,"num not in (", 2048);
do
{
if(list!=g_list_first(list))
g_strlcat(include, ",", 2048);
sprintf(tmp, "%ld", (long int)list->data);
g_strlcat(include, tmp, 2048);
}
while ((list=g_list_next(list)));
g_strlcat(include,")", 2048);
char query[4096]= {0};
sprintf(query,"delete from style_items where styleid=?1 and %s", include);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), query, -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
/* backup style to disk */
char stylesdir[1024];
dt_loc_get_user_config_dir(stylesdir, 1024);
g_strlcat(stylesdir,"/styles",1024);
g_mkdir_with_parents(stylesdir,00755);
dt_styles_save_to_file(newname,stylesdir,TRUE);
/* delete old accelerator and create a new one */
//TODO: sould better use dt_accel_rename_global() to keep the old accel_key untouched, but it seems to be buggy
if (g_strcmp0(name, newname))
{
char tmp_accel[1024];
snprintf(tmp_accel, 1024, "styles/Apply %s", name);
dt_accel_deregister_global(tmp_accel);
gchar* tmp_name = g_strdup(newname); // freed by _destro_style_shortcut_callback
snprintf(tmp_accel, 1024, "styles/Apply %s", newname);
dt_accel_register_global( tmp_accel, 0, 0);
GClosure *closure;
closure = g_cclosure_new(
G_CALLBACK(_apply_style_shortcut_callback),
tmp_name, _destroy_style_shortcut_callback);
dt_accel_connect_global(tmp_accel, closure);
}
g_free(desc);
}
开发者ID:ksyz, 项目名称:darktable, 代码行数:74, 代码来源:styles.c
示例14: settings_window_create
void settings_window_create (void) {
if(win_set_main != NULL) {
gtk_widget_hide(win_set_main);
gtk_widget_show(win_set_main);
return;
}
GtkWidget *vbox_set_m, *hbox_set_m, *but_set_close, *but_set_save, *but_set_reset;
GtkWidget *nb_set_m, *lab_e, *vbox_nb_up, *vbox_nb_um, *vbox_nb_uq;
GtkWidget *hbox_um_s, *grid_uq, *grid_up, *grid_um;
win_set_main = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(win_set_main), "Pomf it! - Settings");
g_signal_connect(win_set_main, "destroy", G_CALLBACK(settings_window_destroy), NULL);
gtk_container_set_border_width(GTK_CONTAINER(win_set_main), 10);
gtk_window_resize(GTK_WINDOW(win_set_main), 320, 200);
gtk_window_set_position(GTK_WINDOW(win_set_main), GTK_WIN_POS_CENTER);
vbox_set_m = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
gtk_container_add(GTK_CONTAINER(win_set_main), vbox_set_m);
nb_set_m = gtk_notebook_new();
gtk_container_add(GTK_CONTAINER(vbox_set_m),nb_set_m);
vbox_nb_up = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
gtk_container_add(GTK_CONTAINER(nb_set_m), vbox_nb_up);
lab_e = gtk_label_new("Uploader");
g_object_set(G_OBJECT(lab_e), "can-focus", FALSE, NULL);
gtk_notebook_set_tab_label(GTK_NOTEBOOK(nb_set_m),
gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb_set_m), 0),lab_e);
vbox_nb_um = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
gtk_container_add(GTK_CONTAINER(nb_set_m), vbox_nb_um);
lab_e = gtk_label_new("Manager");
g_object_set(G_OBJECT(lab_e), "can-focus", FALSE, NULL);
gtk_notebook_set_tab_label(GTK_NOTEBOOK(nb_set_m),
gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb_set_m), 1),lab_e);
vbox_nb_uq = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
gtk_container_add(GTK_CONTAINER(nb_set_m), vbox_nb_uq);
lab_e = gtk_label_new("Queue");
g_object_set(G_OBJECT(lab_e), "can-focus", FALSE, NULL);
gtk_notebook_set_tab_label(GTK_NOTEBOOK(nb_set_m),
gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb_set_m), 2),lab_e);
grid_up = gtk_grid_new ();
gtk_box_pack_start(GTK_BOX(vbox_nb_up), grid_up , FALSE, FALSE, 0);
lab_e = gtk_label_new("Profiles: ");
gtk_grid_attach (GTK_GRID (grid_up),lab_e, 0, 0, 2, 1);
com_upm_pl = gtk_combo_box_text_new();
gtk_grid_attach (GTK_GRID (grid_up),com_upm_pl, 2, 0, 2, 1);
profiles_combo_fill();
hbox_um_s = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
gtk_grid_attach (GTK_GRID (grid_up),hbox_um_s, 4, 0, 4, 1);
GtkWidget *but_up_act = gtk_button_new_with_label("Activate");
g_signal_connect(but_up_act,"clicked",G_CALLBACK(profiles_profile_activate), NULL);
gtk_box_pack_start(GTK_BOX(hbox_um_s),GTK_WIDGET(but_up_act),TRUE,TRUE,0);
GtkWidget *but_up_edit = gtk_button_new_with_label("Edit");
g_signal_connect(but_up_edit,"clicked",G_CALLBACK(profiles_profile_edit), NULL);
gtk_box_pack_start(GTK_BOX(hbox_um_s),GTK_WIDGET(but_up_edit),TRUE,TRUE,0);
hbox_um_s = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
gtk_grid_attach (GTK_GRID (grid_up),hbox_um_s, 8, 0, 4, 1);
GtkWidget *but_up_add = gtk_button_new_with_label("Add New");
g_signal_connect(but_up_add,"clicked",G_CALLBACK(profiles_window_create), NULL);
gtk_box_pack_end(GTK_BOX(hbox_um_s),GTK_WIDGET(but_up_add),TRUE,FALSE,0);
GtkWidget *but_up_del = gtk_button_new_with_label("Delete");
g_signal_connect(but_up_del,"clicked",G_CALLBACK(profiles_profile_delete), NULL);
gtk_box_pack_start(GTK_BOX(hbox_um_s),GTK_WIDGET(but_up_del),TRUE,FALSE,0);
lab_e = gtk_label_new("Active Profile:");
gtk_grid_attach (GTK_GRID (grid_up),lab_e, 0, 1, 2, 1);
lab_profile = gtk_label_new("none");
gtk_grid_attach (GTK_GRID (grid_up),lab_profile, 2, 1, 2, 1);
lab_e = gtk_label_new("Keep SS:");
gtk_grid_attach (GTK_GRID (grid_up),lab_e, 4, 1, 2, 1);
sw_up_kss = gtk_switch_new();
gtk_grid_attach (GTK_GRID (grid_up),sw_up_kss, 6, 1, 2, 1);
grid_um = gtk_grid_new ();
gtk_box_pack_start(GTK_BOX(vbox_nb_um), grid_um , FALSE, FALSE, 0);
lab_e = gtk_label_new("Picture Preview:");
gtk_grid_attach (GTK_GRID (grid_um),lab_e, 0, 0, 2, 1);
sw_um_pp = gtk_switch_new();
gtk_grid_attach (GTK_GRID (grid_um),sw_um_pp, 2, 0, 2, 1);
lab_e = gtk_label_new("Window Size:");
//.........这里部分代码省略.........
开发者ID:BucketPW, 项目名称:pomfit, 代码行数:101, 代码来源:settings.c
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:18285| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9681| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8180| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8551| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8458| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9395| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8431| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7866| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8416| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7394| 2022-11-06
请发表评论