mp3splt-gtk
|
00001 /********************************************************** 00002 * 00003 * mp3splt-gtk -- utility based on mp3splt, 00004 * for mp3/ogg splitting without decoding 00005 * 00006 * Copyright (c) 2005-2011 Alexandru Munteanu - io_fx@yahoo.fr 00007 * 00008 * http://mp3splt.sourceforge.net/ 00009 * 00010 *********************************************************/ 00011 00012 /********************************************************** 00013 * 00014 * This program is free software; you can redistribute it and/or 00015 * modify it under the terms of the GNU General Public License 00016 * as published by the Free Software Foundation; either version 2 00017 * of the License, or (at your option) any later version. 00018 * 00019 * This program is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU General Public License 00025 * along with this program; if not, write to the Free Software 00026 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00027 * USA. 00028 * 00029 *********************************************************/ 00030 00031 #include <gtk/gtk.h> 00032 00033 #include "ui_manager.h" 00034 00035 void ui_set_browser_directory(ui_state *ui, const gchar *directory) 00036 { 00037 ui_infos *infos = ui->infos; 00038 00039 if (infos->browser_directory) 00040 { 00041 g_free(infos->browser_directory); 00042 infos->browser_directory = NULL; 00043 } 00044 00045 if (directory == NULL) 00046 { 00047 infos->browser_directory = NULL; 00048 return; 00049 } 00050 00051 infos->browser_directory = g_strdup(directory); 00052 } 00053 00054 const gchar *ui_get_browser_directory(ui_state *ui) 00055 { 00056 return ui->infos->browser_directory; 00057 } 00058 00059 void ui_set_main_win_position(ui_state *ui, gint x, gint y) 00060 { 00061 if (x == 0 && y == 0) 00062 { 00063 return; 00064 } 00065 00066 ui_main_window *main_win = ui->infos->main_win; 00067 main_win->root_x_pos = x; 00068 main_win->root_y_pos = y; 00069 } 00070 00071 void ui_set_main_win_size(ui_state *ui, gint width, gint height) 00072 { 00073 ui_main_window *main_win = ui->infos->main_win; 00074 main_win->width = width; 00075 main_win->height = height; 00076 } 00077 00078 const ui_main_window *ui_get_main_window_infos(ui_state *ui) 00079 { 00080 return ui->infos->main_win; 00081 } 00082 00083 static void ui_main_window_new(ui_infos *infos) 00084 { 00085 ui_main_window *main_win = g_malloc0(sizeof(ui_main_window)); 00086 00087 main_win->root_x_pos = 0; 00088 main_win->root_y_pos = 0; 00089 00090 main_win->width = UI_DEFAULT_WIDTH; 00091 main_win->height = UI_DEFAULT_HEIGHT; 00092 00093 infos->main_win = main_win; 00094 } 00095 00096 static void ui_infos_new(ui_state *ui) 00097 { 00098 ui_infos *infos = g_malloc0(sizeof(ui_infos)); 00099 00100 ui_main_window_new(infos); 00101 00102 infos->browser_directory = NULL; 00103 00104 ui->infos = infos; 00105 } 00106 00107 ui_state *ui_state_new() 00108 { 00109 ui_state *ui = g_malloc0(sizeof(ui_state)); 00110 00111 ui_infos_new(ui); 00112 00113 return ui; 00114 } 00115 00116 static void ui_main_window_free(ui_main_window **main_win) 00117 { 00118 if (!main_win || !*main_win) 00119 { 00120 return; 00121 } 00122 00123 g_free(*main_win); 00124 *main_win = NULL; 00125 } 00126 00127 static void ui_infos_free(ui_infos **infos) 00128 { 00129 if (!infos || !*infos) 00130 { 00131 return; 00132 } 00133 00134 ui_main_window_free(&(*infos)->main_win); 00135 00136 g_free(*infos); 00137 *infos = NULL; 00138 } 00139 00140 void ui_state_free(ui_state *ui) 00141 { 00142 if (ui) 00143 { 00144 ui_infos_free(&ui->infos); 00145 00146 g_free(ui); 00147 } 00148 } 00149