/** * main: **/ int main (int argc, char *argv[]) { gboolean program_version = FALSE; GpkUpdateViewer *update_viewer = NULL; GOptionContext *context; UniqueApp *unique_app; gboolean ret; const GOptionEntry options[] = { { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version, /* TRANSLATORS: show the program version */ _("Show the program version and exit"), NULL }, { NULL} }; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); if (! g_thread_supported ()) g_thread_init (NULL); dbus_g_thread_init (); g_type_init (); gtk_init (&argc, &argv); context = g_option_context_new (NULL); g_option_context_set_summary (context, _("Add/Remove Software")); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, egg_debug_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); if (program_version) { g_print (VERSION "\n"); return 0; } /* add application specific icons to search path */ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), GPK_DATA G_DIR_SEPARATOR_S "icons"); /* TRANSLATORS: title to pass to to the user if there are not enough privs */ ret = gpk_check_privileged_user (_("Software Update Viewer"), TRUE); if (!ret) return 1; /* are we already activated? */ unique_app = unique_app_new ("org.freedesktop.PackageKit.UpdateViewer", NULL); if (unique_app_is_running (unique_app)) { egg_debug ("You have another instance running. This program will now close"); unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL); goto unique_out; } /* create a new update_viewer object */ update_viewer = gpk_update_viewer_new (); g_signal_connect (unique_app, "message-received", G_CALLBACK (gpk_update_viewer_message_received_cb), update_viewer); g_signal_connect (update_viewer, "action-close", G_CALLBACK (gpk_update_viewer_close_cb), NULL); /* wait */ gtk_main (); g_object_unref (update_viewer); unique_out: g_object_unref (unique_app); return 0; }
void totem_options_process_for_server (UniqueApp *app, const TotemCmdLineOptions* options) { GList *commands, *l; int default_action, i; commands = NULL; default_action = TOTEM_REMOTE_COMMAND_REPLACE; /* Are we quitting ? */ if (options->quit) { unique_app_send_message (app, TOTEM_REMOTE_COMMAND_QUIT, NULL); return; } /* Then handle the things that modify the playlist */ if (options->replace && options->enqueue) { /* FIXME translate that */ g_warning ("Can't enqueue and replace at the same time"); } else if (options->replace) { default_action = TOTEM_REMOTE_COMMAND_REPLACE; } else if (options->enqueue) { default_action = TOTEM_REMOTE_COMMAND_ENQUEUE; } /* Send the files to enqueue */ for (i = 0; options->filenames && options->filenames[i] != NULL; i++) { UniqueMessageData *data; char *full_path; data = unique_message_data_new (); full_path = totem_create_full_path (options->filenames[i]); unique_message_data_set_text (data, full_path ? full_path : options->filenames[i], -1); full_path = totem_create_full_path (options->filenames[i]); unique_app_send_message (app, default_action, data); /* Even if the default action is replace, we only want to replace with the first file. After that, we enqueue. */ default_action = TOTEM_REMOTE_COMMAND_ENQUEUE; unique_message_data_free (data); g_free (full_path); } if (options->playpause) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_PLAYPAUSE)); } if (options->play) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_PLAY)); } if (options->pause) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_PAUSE)); } if (options->next) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_NEXT)); } if (options->previous) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_PREVIOUS)); } if (options->seekfwd) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_SEEK_FORWARD)); } if (options->seekbwd) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_SEEK_BACKWARD)); } if (options->volumeup) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_VOLUME_UP)); } if (options->volumedown) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_VOLUME_DOWN)); } if (options->mute) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_MUTE)); } if (options->fullscreen) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_FULLSCREEN)); } if (options->togglecontrols) { commands = g_list_append (commands, GINT_TO_POINTER (TOTEM_REMOTE_COMMAND_TOGGLE_CONTROLS)); } /* No commands, no files, show ourselves */ if (commands == NULL && options->filenames == NULL) { unique_app_send_message (app, TOTEM_REMOTE_COMMAND_SHOW, NULL); return; } /* Send commands */ for (l = commands; l != NULL; l = l->next) { int command = GPOINTER_TO_INT (l->data); unique_app_send_message (app, command, NULL); } g_list_free (commands); }
int main (int argc, char *argv[]) { TpAccountManager *account_manager; GError *error = NULL; UniqueApp *unique_app; GOptionContext *optcontext; GOptionEntry options[] = { { "hidden", 'h', 0, G_OPTION_ARG_NONE, &hidden, N_("Don't display any dialogs; do any work (eg, importing) and exit"), NULL }, { "if-needed", 'n', 0, G_OPTION_ARG_NONE, &only_if_needed, N_("Don't display any dialogs if there are any non-salut accounts"), NULL }, { "select-account", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &selected_account_name, N_("Initially select given account (eg, " "gabble/jabber/foo_40example_2eorg0)"), N_("<account-id>") }, { NULL } }; g_thread_init (NULL); empathy_init (); optcontext = g_option_context_new (N_("- Empathy Accounts")); g_option_context_add_group (optcontext, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE); if (!g_option_context_parse (optcontext, &argc, &argv, &error)) { g_print ("%s\nRun '%s --help' to see a full list of available command line options.\n", error->message, argv[0]); g_warning ("Error in empathy init: %s", error->message); return EXIT_FAILURE; } g_option_context_free (optcontext); empathy_gtk_init (); g_set_application_name (_("Empathy Accounts")); gtk_window_set_default_icon_name ("empathy"); textdomain (GETTEXT_PACKAGE); unique_app = unique_app_new (EMPATHY_ACCOUNTS_DBUS_NAME, NULL); if (unique_app_is_running (unique_app)) { unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL); g_object_unref (unique_app); return EXIT_SUCCESS; } account_manager = tp_account_manager_dup (); tp_account_manager_prepare_async (account_manager, NULL, account_manager_ready_for_accounts_cb, selected_account_name); g_signal_connect (unique_app, "message-received", G_CALLBACK (unique_app_message_cb), NULL); gtk_main (); g_object_unref (account_manager); g_object_unref (unique_app); return EXIT_SUCCESS; }
int main(int argc, char* argv[]) { gboolean hidden = FALSE; UniqueApp* unique_app; AppShellData* app_data; GSList* actions; GError* error; GOptionEntry options[] = { {"hide", 0, 0, G_OPTION_ARG_NONE, &hidden, N_("Hide on start (useful to preload the shell)"), NULL}, {NULL} }; #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif error = NULL; if (!gtk_init_with_args(&argc, &argv, NULL, options, GETTEXT_PACKAGE, &error)) { g_printerr("%s\n", error->message); g_error_free(error); return 1; } unique_app = unique_app_new("org.mate.mate-control-center.shell", NULL); if (unique_app_is_running(unique_app)) { int retval = 0; if (!hidden) { UniqueResponse response; response = unique_app_send_message(unique_app, UNIQUE_ACTIVATE, NULL); retval = (response != UNIQUE_RESPONSE_OK); } g_object_unref(unique_app); return retval; } app_data = appshelldata_new("matecc.menu", GTK_ICON_SIZE_DND, FALSE, TRUE, 0); generate_categories(app_data); actions = get_actions_list(); layout_shell(app_data, _("Filter"), _("Groups"), _("Common Tasks"), actions, handle_static_action_clicked); create_main_window(app_data, "MyControlCenter", _("Control Center"), "preferences-desktop", 975, 600, hidden); unique_app_watch_window(unique_app, GTK_WINDOW(app_data->main_app)); g_signal_connect(unique_app, "message-received", G_CALLBACK(message_received_cb), app_data); gtk_main(); g_object_unref(unique_app); return 0; }
int start( int argc, char **argv ) { char file[PATH_MAX]; char *f = NULL; char line[7]; int lineToOpen = 0; memset(file,'\0',PATH_MAX); memset(line,'\0',7); gtk_init( &argc, &argv ); //printf("arguments::\n"); for( int i = 0; i < argc; i++ ) { //printf(" argument %d is %s\n",i,argv[i]);fflush(stdout); if( i == 1 ) { strncpy(file,argv[i],PATH_MAX); f = fileFullPath(file); } else if( i == 2 ) { strncpy(line,argv[i],6); lineToOpen = atoi(line); if( lineToOpen < 0 ) lineToOpen = 0; } } g_app = unique_app_new(EDITOR,NULL); if( unique_app_is_running (g_app) ) { char* fl = NULL; int len = 0; UniqueCommand cmd = UNIQUE_NEW; UniqueMessageData* msg = unique_message_data_new(); if( f ) len += strlen(f); if( lineToOpen ) len += strlen(line) + 1; fl = (char*)malloc(len+1); if( f ) { strcpy(fl,f); free(f); if( lineToOpen ) { strcat(fl,"@"); strcat(fl,line); } } if( len > 1 && fl ) { cmd = UNIQUE_OPEN; unique_message_data_set_text(msg,fl,len); free(fl); } unique_app_send_message(g_app,cmd,msg); unique_message_data_free(msg); } else { if(f) free(f); //g_appWin = gtk_window_new(GTK_WINDOW_TOPLEVEL); //unique_app_watch_window (app, GTK_WINDOW(g_appWin)); g_signal_connect(g_app,"message-received",G_CALLBACK(message_received_cb),NULL); MyEditorHandlerLin* meh = (MyEditorHandlerLin*)MyEditorHandlerLin::getInstance(); meh->createEditor(file,lineToOpen); gtk_main(); //gtk_widget_destroy(g_appWin); } g_object_unref (g_app); return 0; }