/* Set image to a themed icon of size from gtk iconset or NULL unless using fallback. * Force allows for the use of packaged icons with a gtk iconset. */ void set_icon(GtkWidget* image, const gchar* icon, int size, gboolean force) { GdkPixbuf* pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image)); if(pixbuf) g_object_unref(pixbuf); if(usefallbacks&&!force) pixbuf = gtk_icon_theme_load_icon(icontheme, icon, size, GTK_ICON_LOOKUP_NO_SVG, NULL); else { char buffer[128]; snprintf(buffer, sizeof(buffer), "%dx%d/%s.png", size, size, icon); pixbuf = gdk_pixbuf_new_from_file(get_iconpath(buffer), NULL); } gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf); }
void create_romBrowser() { GtkWidget* menu; GtkWidget* submenu; GtkWidget* item; australia = gdk_pixbuf_new_from_file(get_iconpath("australia.png"), NULL); europe = gdk_pixbuf_new_from_file(get_iconpath("europe.png"), NULL); france = gdk_pixbuf_new_from_file(get_iconpath("france.png"), NULL); germany = gdk_pixbuf_new_from_file(get_iconpath("germany.png"), NULL); italy = gdk_pixbuf_new_from_file(get_iconpath("italy.png"), NULL); japan = gdk_pixbuf_new_from_file(get_iconpath("japan.png"), NULL); spain = gdk_pixbuf_new_from_file(get_iconpath("spain.png"), NULL); usa = gdk_pixbuf_new_from_file(get_iconpath("usa.png"), NULL); japanusa = gdk_pixbuf_new_from_file(get_iconpath("japanusa.png"), NULL); n64cart = gdk_pixbuf_new_from_file(get_iconpath("16x16/mupen64cart.png"), NULL); /* Setup rombrowser column names. g_MainWindow.column_names[column][0] is the translated column header. g_MainWindow.column_names[column][1] toggles visability in the config system. */ snprintf(g_MainWindow.column_names[0][0], 128, tr("Country")); snprintf(g_MainWindow.column_names[0][1], 128, "ColumnCountryVisible"); snprintf(g_MainWindow.column_names[1][0], 128, tr("Good Name")); snprintf(g_MainWindow.column_names[1][1], 128, "ColumnGoodNameVisible"); snprintf(g_MainWindow.column_names[2][0], 128, tr("Status")); snprintf(g_MainWindow.column_names[2][1], 128, "ColumnStatusVisible"); snprintf(g_MainWindow.column_names[3][0], 128, tr("User Comments")); snprintf(g_MainWindow.column_names[3][1], 128, "ColumnUserCommentsVisible"); snprintf(g_MainWindow.column_names[4][0], 128, tr("File Name")); snprintf(g_MainWindow.column_names[4][1], 128, "ColumnFileNameVisible"); snprintf(g_MainWindow.column_names[5][0], 128, tr("MD5 Hash")); snprintf(g_MainWindow.column_names[5][1], 128, "ColumnMD5HashVisible"); snprintf(g_MainWindow.column_names[6][0], 128, tr("CRC1")); snprintf(g_MainWindow.column_names[6][1], 128, "ColumnCRC1Visible"); snprintf(g_MainWindow.column_names[7][0], 128, tr("CRC2")); snprintf(g_MainWindow.column_names[7][1], 128, "ColumnCRC2Visible"); snprintf(g_MainWindow.column_names[8][0], 128, tr("Internal Name")); snprintf(g_MainWindow.column_names[8][1], 128, "ColumnInternalNameVisible"); snprintf(g_MainWindow.column_names[9][0], 128, tr("Save Types")); snprintf(g_MainWindow.column_names[9][1], 128, "ColumnSaveTypeVisible"); snprintf(g_MainWindow.column_names[10][0], 128, tr("Players")); snprintf(g_MainWindow.column_names[10][1], 128, "ColumnPlayersVisible"); snprintf(g_MainWindow.column_names[11][0], 128, tr("Size")); snprintf(g_MainWindow.column_names[11][1], 128, "ColumnSizeVisible"); snprintf(g_MainWindow.column_names[12][0], 128, tr("Compression")); snprintf(g_MainWindow.column_names[12][1], 128, "ColumnCompressionVisible"); snprintf(g_MainWindow.column_names[13][0], 128, tr("Image Type")); snprintf(g_MainWindow.column_names[13][1], 128, "ColumnImageTypeVisible"); snprintf(g_MainWindow.column_names[14][0], 128, tr("CIC Chip")); snprintf(g_MainWindow.column_names[14][1], 128, "ColumnCICChipVisible"); snprintf(g_MainWindow.column_names[15][0], 128, tr("Rumble")); snprintf(g_MainWindow.column_names[15][1], 128, "ColumnRumbleVisible"); /* Setup rombrowser tree views. */ g_MainWindow.romFullList = gtk_tree_view_new(); g_MainWindow.romDisplay = gtk_tree_view_new(); /* Multiple selections needed due to the way we clear the TreeViews. */ GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_MainWindow.romFullList)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_MainWindow.romDisplay)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); /* Initialize TreeViews - i.e. setup column info. models */ setup_view(g_MainWindow.romFullList); setup_view(g_MainWindow.romDisplay); g_MainWindow.romScrolledWindow = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(g_MainWindow.romScrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); /* Add the Display TreeView into our scrolled window. */ gtk_container_add(GTK_CONTAINER(g_MainWindow.romScrolledWindow), g_MainWindow.romDisplay); gtk_container_add(GTK_CONTAINER(g_MainWindow.toplevelVBox), g_MainWindow.romScrolledWindow); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(g_MainWindow.romDisplay), TRUE); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(g_MainWindow.romDisplay), TRUE); gtk_tree_view_set_reorderable(GTK_TREE_VIEW(g_MainWindow.romDisplay), FALSE); /* Open on double click. */ g_signal_connect(g_MainWindow.romDisplay, "row-activated", G_CALLBACK(callback_play_rom), NULL); /* Setup right-click menu. */ menu = gtk_menu_new(); g_MainWindow.playRomItem = gtk_image_menu_item_new_with_label(tr("Play Rom")); g_MainWindow.playRombrowserImage = gtk_image_new(); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(g_MainWindow.playRomItem), g_MainWindow.playRombrowserImage); g_signal_connect(g_MainWindow.playRomItem, "activate", G_CALLBACK(callback_play_rom), NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu), g_MainWindow.playRomItem); g_MainWindow.romPropertiesItem = gtk_image_menu_item_new_with_label(tr("Rom Properties")); g_MainWindow.propertiesRombrowserImage = gtk_image_new(); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(g_MainWindow.romPropertiesItem), g_MainWindow.propertiesRombrowserImage); g_signal_connect(g_MainWindow.romPropertiesItem, "activate", G_CALLBACK(callback_rom_properties), NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu), g_MainWindow.romPropertiesItem); gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); item = gtk_image_menu_item_new_with_label(tr("Refresh")); g_MainWindow.refreshRombrowserImage = gtk_image_new(); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), g_MainWindow.refreshRombrowserImage); g_signal_connect(item, "activate", G_CALLBACK(callback_call_rcs), NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); item = gtk_menu_item_new_with_label(tr("Configure Rombrowser")); g_signal_connect(item, "activate", G_CALLBACK(callback_configure_rombrowser), NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); submenu = gtk_image_menu_item_new_with_label(tr("Configure Columns")); gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenu), g_MainWindow.romHeaderMenu); gtk_menu_shell_append(GTK_MENU_SHELL(menu), submenu); gtk_widget_show_all(menu); g_signal_connect(g_MainWindow.romDisplay, "button-press-event", G_CALLBACK(callback_rombrowser_context), (gpointer)menu); }